1

我想获取具有 UITextField 的单元格的 indexPath。是否可以获得我们正在使用的当前 UITextField 的 indexPath ?

如果是的话,告诉我真是太棒了,我玩了 2 个小时就快疯了……

多谢 !

4

1 回答 1

3

这应该可以解决问题:

CGPoint location = [sender.superview convertPoint:sender.center toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];

另一种选择是提升视图层次结构。调整您自己的视图层次结构:

UIView *contentView = [textField superview];
UITableViewCell *cell = [contentView superview];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
于 2012-10-11T20:36:06.103 回答