tags:

views:

160

answers:

2

For the Facebook and a few other iPhone apps, I've seen what looks like a UITableView with the top row out of view while the other rows are rendered. Then when the user scrolls up, the the very first row becomes visible. Typically, the top most row is the "load more ..." item.

Is there a trick to having the second row look like the first in the table?

+3  A: 

There are several ways you could do this. The easiest is just to set the tableView's contentOffset to CGPointMake(0, rowHeight). This will basically auto-scroll the first row out of sight. Do this in your viewWilLAppear: method.

Ben Gottlieb
+3  A: 

You can use the scrollToRowAtIndexPath:atScrollPosition:animated: method, without animation, to scroll to the second row when your view is loaded and before it appears:

- (void)viewWillAppear:(BOOL)animated 
{
    [super viewWillAppear:animated];

    // This is just an example... make sure you have at least
    // three items in your table :)
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:2 inSection:0];

    [self.tableView scrollToRowAtIndexPath:indexPath 
                          atScrollPosition:UITableViewScrollPositionTop 
                                  animated:NO];
}
Adrian Kosmaczewski