Reputation: 1087
Ive set a tabbarcontroller in my main window. One of its tabs is a navigation controller with a rootview X that pushes to view Y.
The problem is: when the navigation controller has pushed view Y and I tap on the tab corresponding to the rootview X, the app tries to show the rootview X again, when the app should do nothing.
That shouldnt happen, right? The content inside a tab shouldnt change at all if im still on that tab, right?
Upvotes: 0
Views: 78
Reputation: 16827
If you tap on the tab were you currently are, the default behaviour for the embedded navigation controller is to pop to the root view controller. You can change this by setting a delegate to the UITabBarController and overiding the UITabBarControllerDelegate method
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
and providing custom behaviour when viewController == tabBarController.selectedViewController (note that you will be receiving the navigation controller, which is a subclass of UIViewController, not the root view controller of the navigation controller).
Upvotes: 1