从“可见"获取UITableviewCell位置.区域或窗口 [英] Get UITableviewCell position from "visible" area or window
问题描述
我在uitableview和uitabbar的基础上创建了一个iPhone应用程序.在表格视图的每个单元格上,我都有一个添加到收藏夹按钮". 当我按下此按钮时,我想使单元格从她的位置跳到"标签栏的收藏夹项(与installous中的下载效果相同)
I create an iPhone app base on uitableview and uitabbar. On each cell of tableview i have an "add to favorite button". When i pressed this button, i want to make the cell "jump" from her position to the favorite item of the tabbar (same as download effect in installous)
如果我在前10个单元格上,效果会很好,但是如果我在tableView中滚动,则效果不好,因为开始位置是根据uitableview大小计算的.
The effect work well if i'am on top 10 cell, but if i scroll in the tableView the effect is not good because start position is calculate from uitableview size.
可以从可见区域知道单元格的位置. ?
It's possible to know the position of a cell from the visible area. ?
示例:对于第四十个单元格位置是x:0,y:1600,w:320,y:50,我想要从屏幕顶部而不是uiview顶部的位置,所以像这样的x: 0,y:230,w:320,y:50
Exemple : for the fortieth cell position is x:0,y:1600,w:320,y:50, i want the position from the top of the screen not from the top of the uiview so something like this x:0,y:230,w:320,y:50
推荐答案
是的,您可以使用rectForRowAtIndexPath:
,您只需传递您单击的行的indexPath.
Yes you can use rectForRowAtIndexPath:
you'll just have to pass in the indexPath of your row you've clicked.
rectForRowAtIndexPath:
返回一行的绘图区域 通过索引路径标识.
Returns the drawing area for a row identified by index path.
...
编辑
转化:
CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
CGRect rectInSuperview = [tableView convertRect:rectInTableView toView:[tableView superview]];
这篇关于从“可见"获取UITableviewCell位置.区域或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!