Reputation: 15894
I've having tab view controller in my MainWindow.xib file. It has 3 tabs. The view controllers for each tab is also assigned in XIB only. I want to prevent tab 3 being displayed depending on some condition check.
I know that I've to implement the delegate method:
- (BOOL)tabBarController:(UITabBarController *)tbController shouldSelectViewController:(UIViewController *)viewController
But how can I check if its third tab or not? So if its third tab, i'll return NO, else I'll return YES.
Upvotes: 0
Views: 1009
Reputation: 38475
// This should tell you the tab index
NSInteger tabIndex = [[tbController viewControllers] indexOfObject:viewController];
// Then it's easy
return tabIndex != 3;
Upvotes: 2