How to get UITableViewCell indexPath from the Cell?

后端 未结 11 1621
野趣味
野趣味 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:28

    The answer to this question actually helped me a lot.

    I used NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];

    The sender in my case was a UITableViewCell and comes from the prepareForSegue method.

    I used this because I did not have a TableViewControllerbut i had UITableView property outlet

    I needed to find out the title of the Cell and hence needed to know the indexPath of it.

    Hope this helps anyone!

提交回复
热议问题