我試圖找到UITableViewCell
當用戶按UIButton
這是一個subview
單元格的行。使用下面的代碼,我可靠地得到比實際的indexpath
少一個。任何人都知道爲什麼這是/如果這是在iOS7中使用subview
(在本例中爲UIButton
)找到單元的indexpath
的好方法?在uitableviewcell中的uibutton給我的indexpath小於實際的indexpath iOS7
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:_messageTableView];
NSIndexPath *indexPath = [_messageTableView indexPathForRowAtPoint:buttonPosition];
if (indexPath != nil)
{
NSLog(@"highlightedcell: %i",indexPath.row);
}
將'CGPointZero'改爲'CGPointMake(5,5)',你應該得到更好的結果。 – rmaddy