I have a UITabBar
application with 8 tabs in my iPhone app.
So how shall I reset back to the 'more' tab table everytime 'more' is clicked?
I tried the following delegate method in AppDelegate.m
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSLog(@"controller class: %@", NSStringFromClass([viewController class]));
NSLog(@"controller title: %@", viewController.title);
if (viewController == tabBarController.moreNavigationController)
{
tabBarController.moreNavigationController.delegate = self;
}
if ([viewController isKindOfClass:[UINavigationController class]])
{
[(UINavigationController *)viewController popToRootViewControllerAnimated:NO]; //All viewControllers are UINavigationController classes in my app
}
}
@property(nonatomic, readonly) UINavigationController *moreNavigationController
is responsible for the navigation at the More
item, you need to use it when you want to navigate to the root of the item:
[tabBarController.moreNavigationController popToRootViewControllerAnimated:NO];