2012-10-11 47 views

回答

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]; 
+0

如果文本字段未直接添加到單元格的contentView,則第二個選項將失敗。第一個選項沒有這個問題。 – rmaddy

相關問題