I would like to completely reset the scroll position of a UITableView, so that every time I open it, it is displaying the top-most items. In other words, I would like to scroll the table view to the top every time it is opened.
I tried using the following piece of code, but it looks like I misunderstood the documentation:
- (void)viewWillAppear:(BOOL)animated { [tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:NO]; }
Is this the wrong approach here?
August got the UITableView-specific method. Another way to do it is:
This method is defined in UIScrollView, the parent class to UITableView. The above example tells it to scroll to the 1×1 box at 0,0 – the top left corner, in other words.