How to make specific UITableViewCell to be visible on screen while having more rows in UITableView

I found the easiest way to ensure that a whole cell is visible is to ask the tableview to make sure that the rect for the cell is visible:

[tableView scrollRectToVisible:[tableView rectForRowAtIndexPath:indexPath] animated:YES];

An easy way to test it is just to put that into -(void)tableView:didSelectRowAtIndexPath: - tapping any cell will then scroll it into place if it's partially hidden.


UITableView class offers :

-(void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
             atScrollPosition:(UITableViewScrollPosition)scrollPosition
                     animated:(BOOL)animated;

which seems to be what you are looking for.

The NSIndexPath object can be built using :

+(NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;

Try scrollToRowAtIndexPath:atScrollPosition:animated::

NSUInteger indexArray[] = {1,15};
NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:2];
[yourTableView scrollToRowAtIndexPath:indexPath atScrollPosition: UITableViewScrollPositionTop animated:YES];