I want to save the current tab the user is in when the user quits the application, so I can load the application with that tab highlighted when the user re-enters the app.
I presume I use the following method within my app delegate to save the current tab
- (void)applicationWillTerminate:(UIApplication *)application
but how do I gain access to the current tab – and what would be the best way to reload it?
In applicationWillTerminate, save the selectedIndex of the tabbarcontroller to your defaults.
Then on startup, read in index from NSDefaults and then set the tab.
setIndex is an NSUInteger. Then set the TabBarController in your viewDidLoad like so:
This is from memory, so you’ll need to try it out, but this is the general approach.
Cheers, Jordan