Reputation: 183
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 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??
Upvotes: 1
Views: 363
Reputation: 80271
- (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.
Upvotes: 1
Reputation: 31304
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
Upvotes: 0