Reputation: 2923
I have 3 TabBarItems
in UITabBarController
:
<UINavigationController: 0xc76a680>
<SplitViewController: 0xc76a170>
<UINavigationController: 0xca5e6f0>
And I have the method in AppDelegate
:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
NSLog(@"tab selected index %@",viewController);
if (viewController == nil ) // I NEED TO IMPLEMENT A CHECk HERE
{
//show popup
return NO; //does not change the tab
}
return YES; //does change the tab
}
So how to check that view controller which should be selected is the second Navigation Controller? Thx
Upvotes: 0
Views: 1675
Reputation: 12023
try this code
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
BOOL result;
if (viewController == [self.tabBarController.viewControllers objectAtIndex:2]) //assuming the index of uinavigationcontroller is 2
{
NSLog(@"Write your code based on condition");
result = NO;
}
else {
result = YES;
}
return result;
}
Upvotes: 6
Reputation: 63
You could check for viewcontroller.title property and then make the decision. Assuming that title for both viewcontrollers are different.
Upvotes: 0