Getting the exact location of a UITableViewCell

后端 未结 9 596
滥情空心
滥情空心 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条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 20:54

    Try the following(sending nil as a toView parameter means you want to convert you rect to window coordinates):

    CGRect r = [cell convertRect:cell.frame toView:nil];
    

    And remember that if particular row is not currently visible then there may not be UITableViewCell for it - so before using that code you may need to check if cell is valid (not nil for example)

提交回复
热议问题