How to get UITableViewCell indexPath from the Cell?

后端 未结 11 1640
野趣味
野趣味 2020-12-07 20:11

How do I, from a cell, get its indexPath in a UITableView?

I\'ve searched around stack overflow and google, but all the information is on t

11条回答
  •  不知归路
    2020-12-07 20:37

    Try with this from your UITableViewCell:

    NSIndexPath *indexPath = [(UITableView *)self.superview indexPathForCell: self];
    

    EDIT: Seems this doesn't work on iOS 8.1.2 and further. Thanks to Chris Prince for pointing it.

提交回复
热议问题