获取UITableViewCell的确切位置 [英] Getting the exact location of a UITableViewCell

查看:87
本文介绍了获取UITableViewCell的确切位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定 UITableView ,如何找到特定 UITableViewCell 的位置?换句话说,我希望相对于我的iPhone屏幕获取其帧,而不是相对于 UITableView 。因此,如果我的 UITableView 向上滚动,则每个 UITableViewCell 的位置应该在屏幕上更高等等。

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.

推荐答案

您还可以使用 rectForRowAtIndexPath 方法获取<的位置code> UITableView 发送 indexPath

You could also use the rectForRowAtIndexPath method to get the location of a UITableView by sending the indexPath for that.

- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

请按以下方式使用:

CGRect myRect = [tableView rectForRowAtIndexPath:indexPath];

这篇关于获取UITableViewCell的确切位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆