Have you noticed that when you go through emails in the Mail app using the up/down arrows and return to the list view that it’s scrolled to the last email you looked at?

It’s a slick piece of functionality, and one that’s easy to implement.

Assuming you have a UISegmentedControl like the one in the Mail app, you just need to add the following code to your action method:

NSArray *controllers = [self.navigationController viewControllers];

// retrieves the parent view controller
UITableViewController *parentViewController = [controllers
    objectAtIndex:[controllers count] – 2];

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex
    inSection:sectionIndex];

[parentViewController.tableView scrollToRowAtIndexPath:indexPath
    atScrollPosition:UITableViewScrollPositionTop animated:NO];


You’ll have to keep track of the section and row indicies for each subview, but that’s about it.

As you move through your subviews the parent view controller will adjust its scroll position to match, and when you return to the UITableView the last item you viewed will be visible in the list.