Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get UITableviewCell position from "visible" area or window

Tags:

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)

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. ?

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

like image 253
Mickael Avatar asked May 08 '11 09:05

Mickael


1 Answers

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.

...

EDIT

Conversion:

CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath]; CGRect rectInSuperview = [tableView convertRect:rectInTableView toView:[tableView superview]];  
like image 102
Nick Weaver Avatar answered Oct 13 '22 21:10

Nick Weaver