Reputation: 9120
I'm trying to implement a tab bar in iOS application:
But when users tab item 1 I need to release the second viewController.
I setup UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
{
if (tabBarController.selectedIndex == 0)
{
UINavigationController *navController = (UINavigationController*)viewController;
[navController popToRootViewControllerAnimated:NO];
}
}
But when I tab in item one I get this error:
[ViewController popToRootViewControllerAnimated:]: unrecognized selector sent to instance
My question is. What I'm doing wrong. I'm trying to release the second item in my tab bar. There is another way I can release the second item in my tab bar?
Upvotes: 0
Views: 275
Reputation: 15331
Think you mean.
if (tabBarController.selectedIndex == 0)
{
UINavigationController *navController = [tabBarController.viewControllers objectAtIndex:1];
[navController popToRootViewControllerAnimated:NO];
}
But even that won't do what you want. You need to set navController's rootViewController with a new instance of RootViewController.
Upvotes: 1