欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

use UINavigationController inside a UITabBarController

程序员文章站 2022-03-02 10:49:00
...
If you want to add a UINavigationController into a TabView, and while the tab was taped,turn current view to display rootView of the UINavigationController.Keep following principles.


1,Don't put the view which is expected to display into TabView straightly.

2,Instead of 1,wrap the view by a NavigationController,then put the NavigationController into TabView.


      loginViewController = [[[LoginViewController alloc] init]autorelease];
loginViewController.title = @"Setting";

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController2] ;


self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, navigationController,loginViewController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];