1
我想獲得具有UITextField的單元格的indexPath。是否有可能獲得我們正在使用的當前UITextField的indexPath?如何獲得單元格的索引路徑當我使用它
如果是的話,這將是真棒告訴我,我得到,因爲它2小時瘋了...
非常感謝!
我想獲得具有UITextField的單元格的indexPath。是否有可能獲得我們正在使用的當前UITextField的indexPath?如何獲得單元格的索引路徑當我使用它
如果是的話,這將是真棒告訴我,我得到,因爲它2小時瘋了...
非常感謝!
這應該做的伎倆:
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];
如果文本字段未直接添加到單元格的contentView,則第二個選項將失敗。第一個選項沒有這個問題。 – rmaddy