I’m implementing UITabBar in my app. I managed making it work by implementing UITabBarDelegate in my header file and using
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
in my .m file (as explained in this tutorial).
Now, there are 3 scenarios in my app where I wish to set the selected UITabBarItem manually from within the code (and not based on user action):
- Upon
viewDidLoad - After
didReceiveMemoryWarning - In a certain case when the user is entering another view controller – when they get back, they should get back to a different tab than the one they clicked on.
Can anyone direct me to how this should be done?
The
UITabBarControllerclass has two properties for managing the selected tab, namely,selectedViewControllerandselectedIndex. Look into those in the reference.