Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll UITableView to specific position

How can I scroll the table's cell to specific position ? I have a table which shows 3 rows (according to height). what I want is if I click on 1st row than according to table's height the 1st row should scroll and get new position (center) and same for other rows. I tried contenOffset but did not work..

EDITED :

In short some thing like data picker when we select any row in picker the row scrolls to the center.

Thanks..

like image 682
Maulik Avatar asked May 02 '11 11:05

Maulik


1 Answers

it should work using - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated using it this way:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [yourTableView scrollToRowAtIndexPath:indexPath                       atScrollPosition:UITableViewScrollPositionTop                               animated:YES]; 

atScrollPosition could take any of these values:

typedef enum { UITableViewScrollPositionNone, UITableViewScrollPositionTop, UITableViewScrollPositionMiddle, UITableViewScrollPositionBottom } UITableViewScrollPosition; 

I hope this helps you

Cheers

like image 97
Fran Sevillano Avatar answered Sep 22 '22 07:09

Fran Sevillano