开发者

TabBarController in a NavigationConroller

开发者 https://www.devze.com 2023-03-05 15:12 出处:网络
I have a UITabBarController within a UINavigationController, I know the iOS documentation for the UINavigationController says the following:

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 t开发者_如何学JAVAhe 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消