How to get UITableViewCell indexPath from the Cell?

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

    You can try this simple tip:

    on your UITableViewCell Class :

    @property NSInteger myCellIndex; //or add directly your indexPath 
    

    and on your cellForRowAtIndexPath method :

    ...
    [cell setMyCellIndex : indexPath.row]
    

    now, you can retrieve your cell index anywhere

提交回复
热议问题