views:

36

answers:

1

Hi!

I have a UITabBarController which has been created programatically. There are 6 tabs within the tab bar which has forced a more button to appear, which is great and works beautifully!

Whilst testing the app, one of the testers raised a point. When they select the more button, then select one of the options in the more menu, the resulting view is presented as expected. If they then select another tab from the tab bar and subsequently return to the more tab the view that they previously selected is still visible!

So, my question is this. How can I make the "more" button return to the table menu when it is selected? I have tried the obvious, as it is appears to be a subclass of UINavigationController I tried popping to root etc but to no avail... The iPod app does exactly what I want to do so I know its possible, just wondering if there is something I am missing?

Any help is appreciated

Graham Whitehouse

+1  A: 

Try this delegate method:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    if ([tabBarController selectedIndex] > 3) {
        [viewController.navigationController popToRootViewControllerAnimated:NO];
    }
}
MattLeff
Hi Matt, thanks for the response however it didn't work... I had tried the popToRootViewController call within the delegate previously to no avail! It seems the more button creates a subclassed version of the UINavigationController, when you look at the data type of the viewController within the delegate method it is defined as a UIMoreNavigationController. I am guessing the is something there that will allow me to do what I want to do...
Graham Whitehouse
Graham, I tried this in my app as I need to do a similar thing and it worked for me. `UIMoreNavigationController` is a private class so there is nothing more there unless you want to risk the API police. `UIMoreNavigationController` does extend `UINavigationController` so you should be able to call `popToRootViewControllerAnimated:` on it. Is it just not popping or is it crashing? What version of the SDK are you building against?
MattLeff