Prevent automatic popToRootViewController on double-tap of UITabBarController
Solution 1:
Use the tabBarController:shouldSelectViewController: method of the UITabBarControllerDelegate protocol.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return viewController != tabBarController.selectedViewController;
}
Don't forget to set the delegate of the tab bar controller to the object that actually implements this delegate method.
Solution 2:
this is what I did:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if ([[tabBarController viewControllers] objectAtIndex:[tabBarController selectedIndex]] == viewController)
return NO;
return YES;
}
regards