I have a UITabBarController as the rootViewController in the storyboard of an iPad app.
It contains 3 tabBarItems.
Each item holds a navigationController.So total 3 navigationControllers.
Scenario:
I select the 2nd tabBarItem. Then the 2nd navigationController will become visible on the tabBarController with the view of its associated rootController.
I push some controllers on this visible navigationController.
Now, when I tap of the 2nd tabBarItem ( which is already selected now ), the tabBarController pops-up all the pushed controllers and brings the navigationController to its rootController view.
Question: How can I stop this behaviour ? A selected tabBarItem should not do any action when the user taps on it again.
If you init the UITabBarController in rootViewController add UITabBarControllerDelegate in rootViewController, and implement this delegate:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
UIViewController* selected = [tabBarController selectedViewController];
if (viewController == selected)
return NO;
else
return YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With