gpt4 book ai didi

ios - 未检测到 UITableViewCell 内的 TableView

转载 作者:行者123 更新时间:2023-11-29 13:17:53 24 4
gpt4 key购买 nike

我有两个 UITableView:tableviews1 和 tableview2。

tableview2 在 tableview1 的 UITableViewCell 里面。当我点击 tableview2 的 uitableviewcell 时,它没有响应,但检测到 tableview1 tableviewcell。

谁能帮忙解决这个问题?

这是我正在使用的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (tableView == orderFoodDetailTableview) {

if (cell == nil) {

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

cell.selectionStyle = UITableViewCellSelectionStyleNone;

}
}
else {


cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

[self addUItableViewAsSubView :cell];

}

cell.selectionStyle = UITableViewCellSelectionStyleGray;
}

return cell;
}



- (void)addUITableViewAsSubView:(UITableViewCell *)cell{

portionSelected_yVal = [sArray count]*25;
portionTableview = [[UITableView alloc]initWithFrame:CGRectMake(10, height+53, 140, portionSelected_yVal)];
portionTableview.delegate = self;
portionTableview.dataSource = self;
portionTableview.backgroundColor = [UIColor clearColor];
portionTableview.hidden = YES;
portionTableview.layer.borderColor=[UIColor blackColor].CGColor;
portionTableview.layer.borderWidth=1.0f;
portionTableview.layer.cornerRadius=2.0f;
[cell addSubview:portionTableview];
}

最佳答案

对于您提到的目的(在您的评论中),您可以动态调整 TableView1UITableViewCell 的高度,同时用户触摸 tableviewcell。再次触摸该单元格,您可以将其调整回正常大小。

我希望你明白我的意思。


编辑

您必须检查要对哪个 tableView 执行 UITableView 的常用委托(delegate)方法中的操作。

比如说你有两个 TableView T1 和 T2。

然后在下面的方法中,您必须首先检查是针对哪个 TableView (T1 或 T2)调用了该方法。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (tableView == T1)
// Return number of sections for T1;
else if (tableView == T2)
// Return number of sections for T2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == T1)
// Return number of rows for T1;
else if (tableView == T2)
// Return number of rows for T2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == T1)
// Create and Return cell for T1;
else if (tableView == T2)
// Create and Return cell for T2;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == T1)
// Do stuff for T1 related actions;
else if (tableView == T2)
// Do stuff for T2 related actions;
}

清楚了吗?

关于ios - 未检测到 UITableViewCell 内的 TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15197243/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com