Choosing an optional navigation controller
To select moreNavigationController, you must set selectedViewController :
self.tabBarController.selectedViewController = self.tabBarController.moreNavigationController;
The reason is that it is simple: the NavigationController is no longer inside the viewControllers the tab bar controller, so it cannot be selected by index.
To select one of the "more" controllers directly, you can set the selectedViewController property:
self.tabBarController.selectedViewController = viewController5;
Or you can install selectedIndex :
self.tabBarController.selectedIndex = 5;
Locking the displayed tab bar
The disappearing image of the tab bar is caused by the use of the navigation controller (for settings) inside the navigation controller ( moreNavigationController generated by the tab bar controller). To fix this, there are two solutions:
Do not add navigation controllers for a larger section, but add controllers directly. The structure of the controller will look like this, assuming that the controllers in all tabs need navigation:
tabBarController + navigationController + viewController0 + navigationController + viewController1 + navigationController + viewController2 + navigationController + viewController3 + viewController4 + viewController5
Install the tabBarItem controller tabBarItem on your navigation controller (you only need to do this once):
UINavigationController *settingsNavigationController = [appDelegate.objTabBarController objectAtIndex:5]; UIViewController *settingsRootController = settingsNavigationController.viewControllers[0]; settingsNavigationController.tabBarItem = settingsRootController.tabBarItem;
Tammo freese
source share