我的应用在 iOS 6.1 上运行良好。我尝试了 iOS 7 模拟器,以下部分不起作用:
EditingCell *cell = (EditingCell*) [[textField superview] superview];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
NSLog(@"the section is %d and row is %d", indexPath.section, indexPath.row);
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSString *rowKey = [[keysForRows objectAtIndex: section] objectAtIndex: row];
它总是到来:
the section is 0 and row is 0
尽管选择了另一部分/行,但为什么在iOS7下无法正常工作?
[[textField superview] superview]
是引用任何内容的一种相当糟糕的方式。 - DesdenovaNSLog(@"Class of Cell: %@", NSStringFromClass(cell.class));
还可以研究一下UITableView的方法“indexPathOfSelectedCell”。希望能有所帮助。 - katzenhut