use UINavigationController inside a UITabBarController

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];

你可能感兴趣的:(controller)