Getting the exact location of a UITableViewCell

后端 未结 9 598
滥情空心
滥情空心 2021-01-30 20:10

Given a UITableView, how can I find the location of a specific UITableViewCell? In other words, I want to get its frame relative to my iPhone screen, n

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 21:08

    Apart from rectForRowAtIndexPath you need to consider the scrolling.

    Try this code:

     // Get the cell rect and adjust it to consider scroll offset
     CGRect cellRect = [tableView rectForRowAtIndexPath:indexPath];
     cellRect = CGRectOffset(cellRect, -tableView.contentOffset.x, -tableView.contentOffset.y);
    

提交回复
热议问题