Brian
Brian

Reputation: 151

TabBarController in a NavigationConroller

I have a UITabBarController within a UINavigationController, I know the iOS documentation for the UINavigationController says the following:

rootViewController

The view controller that resides at the bottom of the navigation stack. This object cannot be an instance of the UITabBarController class.

So does this mean that if I have UIViewControllers already on the navigation stack, it's ok then to push a UITabBarController, once it's not the root item?

I have this at the moment and all seems ok except when I pop the UITabBarController, the dealloc or viewDidUnload isn't called in any of the TabBarItems ViewController, do I need to do something similiar for getting the viewWillAppear to work?

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {  
[viewController viewWillAppear:NO];
}

Thanks

Upvotes: 0

Views: 361

Answers (1)

Jeremy Bassett
Jeremy Bassett

Reputation: 171

I am not sure that having a UITabBarController within a UINavigationController is going to work.

I usually do this the other way round

companyNavController = [[[UINavigationController alloc] initWithRootViewController:companyViewController] autorelease];
companyNavController.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1];

[tabBarController setViewControllers:[NSArray arrayWithObjects:phoneBookNavController, companyNavController, faveNavController, settingsNavController, nil]];

If you'd like to hide the TabBar part of your App, you could always try hidesBottomBarWhenPushed to manage this.

HTH

Upvotes: 1

Related Questions