How do I integrate popToRootViewControllerAnimated with my tabs?

Posted by Adam Storr on Stack Overflow See other posts from Stack Overflow or by Adam Storr
Published on 2010-12-20T07:42:07Z Indexed on 2010/12/21 8:54 UTC
Read the original article Hit count: 363

Hello!

I am trying to make one of my tab buttons go to the root using popToRootViewControllerAnimated. My question is: where do I put this code for it to work? I have my tabs created through Interface Builder... do they have to be hard coded for this to work?

Here is the code that I'm looking to use:

[self.navigationController popToRootViewControllerAnimated:YES];

New code in AppDelegate:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    if (viewController = HomeViewController) {
        [HomeViewController popToRootViewControllerAnimated:NO];
    }
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk-3.0