我正在尝试制作手风琴tableview
。在这里,我可以轻松获得parent tableview
个选定的单元索引路径值,但我无法获得子表(Expandable child
tableview cell)row index path
。请给我解决我的问题,并找到下面的代码
我的代码:
// @optional
- (void)didSelectRowAtChildIndex:(NSInteger)childIndex underParentIndex:(NSInteger)parentIndex {
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:[self rowForParentIndex:parentIndex] inSection:0];
UITableViewCell *selectedCell = [self cellForRowAtIndexPath:indexPath];
if ([selectedCell isKindOfClass:[ParentTableViewCell class]]) {
//ParentTableViewCell * pCell = (ParentTableViewCell *)selectedCell;
// Insert code here to detect and handle child cell selection
// ...
}
}
我正在使用开源代码进行检查:https://github.com/ajkoshy7/SubTable
答案 0 :(得分:1)
从childIndex获取所选Child的索引路径:
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:[self rowForParentIndex:parentIndex] inSection:0];
NSIndexPath * indexPathChild = [NSIndexPath indexPathForRow:[self rowForParentIndex:childIndex] inSection:indexPath.row];