问题描述
所以,我有这个 UITableView
。它在一个iPad应用程序。一些单元格在右边有一个附件按钮(小圆形箭头)。当按下时,我提出一个popover视图,用户可以选择与他们触摸的表单元格相关的操作。到目前为止,没有什么是困难的或例外。
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.
但是popover视图想知道它的起源,所以它可以画出指向那里的小箭头。我自然会喜欢这个箭头指向popover所关联的表格单元格。
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?
推荐答案
使用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:
.
这篇关于获取某个UITableViewCell的屏幕坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!