Cocoa – Switching between two UITableViewControllers within a single UINavigationController


I have a UINavigationController. In its toolbar is a segmented control with two buttons. Each button relates to its own UITableViewController.

What I'm trying to achieve is someway of wiring up the navigation controller so that the views are switched depending on which button within the segmented control is active.

I assume I should hold on to the table controllers, because I want to preserve the scrolling position within each view, e.g., if the user was positioned at the top of table 1, and the bottom of table 2, then this information should be preserved when switching.

Any suggestions would be gratefully received!

Best Solution

Would it be possible to just switch the dataSource instead of having to deal with two separate table views? Preserving the scrolling position can still just as easily be done, and you end up using less memory (one table view and two data sources instead of two table views and two data sources).

With only 128MB to spare, memory efficiency is king on the iPhone.

Related Question