I'm using some code I found on the web to save the last loaded tab. In my app delegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
// .. my app set up is here
// Select the tab that was selected on last shutdown
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger whichTab = [defaults integerForKey:kSelectedTabDefaultsKey];
self.tabBarController.selectedIndex = whichTab;
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Save the current tab so the user can start up again in the same place.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger whichTab = self.tabBarController.selectedIndex;
[defaults setInteger:whichTab forKey:kSelectedTabDefaultsKey];
}
and the definition in my interface file:
#define kSelectedTabDefaultsKey @"SelectedTab"
This works unless the user rearranges the tabs, in which case you have to update the array of tabs (the index will change).
Here's the original page where I found the code:
http://iphonedevelopment.blogspot.com/2009/09/saving-tabs.html
I'm using this code on a tabbed interface which shows the "More..." tab. When I quit on a tab under the "More..." part, the interface comes back to that tab when I restart the app. The interface won't restart on the "More..." table view, but I don't consider that a problem.