我有一个 tableview
,它位于 tableview 单元格内。我需要该子 TableView “cellForRowAtIndexPath”方法中的主 TableView 索引路径。我坚持这一点。我的数据源和委托(delegate)方法在同一个类中。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Configure the cell...
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil && [tableView tag] == 200) {
//main tableview
}
else if(cell == nil && tableView.tag == 106)
{
//sub tableview
here I need the index path of main tableview
}
}
如何获取主 TableView 的索引路径?
最佳答案
试试这个:
UITableViewCell *cell = (UITableViewCell *) tableView.superview.superview.superview;
UITableView *curTableView = (UITableView *)cell.superview;
NSIndexPath *indexPath = [curTableView indexPathForCell:cell];
关于ios - IOS 中的索引路径嵌套 Tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17439999/