获取某个 UITableViewCell 的屏幕坐标?

发布于 2024-09-12 21:06:24 字数 265 浏览 6 评论 0原文

所以,我有这个UITableView。它位于 iPad 应用程序中。有些单元格的右侧有一个附件按钮(小圆形箭头)。当按下该按钮时,我会呈现一个弹出视图,用户可以在其中选择与他们触摸的表格单元格相关的操作。到目前为止,这一切都不是困难的或特殊的。

但是弹出视图想要知道它来自哪里,以便它可以绘制指向那里的小箭头。我自然希望该箭头指向与弹出窗口相关的表格单元格。

如果我知道表中某个单元格的索引路径,如何找出它当前的屏幕坐标?

So, I have this UITableView. It's in an iPad application. Some of the cells have an accessory button on the right (the small round arrow). When that is pressed, I present a popover view where the user can select actions related to the table cell that they touched. So far, nothing of this is difficult or exceptional.

But the popover view wants to know where it originates from, so that it can draw the little arrow pointing there. I would naturally like that arrow to point at the table cell the popover relates to.

How can I find out the current on screen coordinates for a certain cell in a table, given that I know it's indexPath?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一影成城 2024-09-19 21:06:24

使用 UITableView 方法 -rectForRowAtIndexPath:。请注意,这将返回表视图坐标系中的一个矩形 - 如果您需要相对于同一窗口中另一个视图的矩形,请使用 UIView 方法 -convertRect:fromView:

Use the UITableView method -rectForRowAtIndexPath:. Note that that returns a rect within the table view’s coordinate system—if you need the rect relative to another view within the same window, use the UIView method -convertRect:fromView:.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文