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, not relative to the UITableView. So if my UITableView is scrolled up, the location of each UITableViewCell should be higher on the screen, etc.
You could also use the rectForRowAtIndexPath method to get the location of a UITableView by sending the indexPath for that.
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath So use as below:
CGRect myRect = [tableView rectForRowAtIndexPath:indexPath];
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With