UITabBar and UINavigationController
Let me make the question more clear.
I have tab bar application with navigation controller included in each tab.
When click the tab 2 i go to login screen. From login screen i navigate to next screen (say screen 2) using login button. When i am on screen 2 if i cilck the tab开发者_Go百科 2 i again go to login screen. I do not want this. I want application to remain at same screen even if tab 2 is clicked again.
If i cilck any other tab in between then it works as expected.
How to achieve this??
- (BOOL)tabBarController:(UITabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController {
if ([tabBarController.selectedViewController isEqual:viewController])
return NO;
}
return YES;
}
Alternatively, you can catch taps on the tab bar and check if the selectedIndex
changed or not.
The UITabBarController
will pop to the root view controller if you tap a tab that you are currently displaying. To prevent this behavior take a look at this question:
Disable action - user taps on tabbar item to go to root view controller
精彩评论