Syl*_*sot 6 xcode uitableview nsindexpath
我有一个包含两个动作的tableview,第一个我使用委托didSelectRowAtIndexPath,第二个我想在我的单元格上的按钮上使用动作来做其他事情.我的问题是我没有成功获得索引路径?这样做的最佳做法是什么?
如果您已将按钮添加到单元格中,
[cell.contentView addSubview:button];
Run Code Online (Sandbox Code Playgroud)
那么,你可以获得索引路径,
- (void)onButtonTapped:(UIButton *)button {
UITableViewCell *cell = (UITableViewCell *)button.superview.superview;
NSIndexPath *indexPath = [tableView indexPathForCell:cell];
// Go ahead
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9975 次 |
| 最近记录: |