1. display the label bar and navigation bar directly on the Root View Controller
There is only one Root View Controller. Add the following code to the (BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) lanuchOptions method in the AppDelegate. m file:
// Create the navigation bar object UINavigationController * pNavigation = [[UINavigationController alloc] initWithRootViewController: self. viewController]; // create another Class Object LinAnotherViewController * pAnotherVC = [[LinAnotherViewController alloc] initWithNibName: nil bundle: nil]; // create the Tabbar object UITabBarController * pTabBar = [[UITabBarController alloc] init]; // initialize the array and store the content of the label bar NSArray * pArray = [NSArray arrayWithObjects: pNavigation, pAnotherVC, nil]; // pass the content in the array to the label bar controller pTabBar. viewControllers = pArray; // sets the Root View Controller self. window. rootViewController = pTabBar;
In this case, the view is empty. You can add the corresponding controls, images, and attributes of the navigation bar and label bar according to the previous learning method.
2. Create a New Root View Controller and display the tab bar and navigation bar after the switch interface
When you need to display the label bar and navigation bar after the page Jump, you should set a new Root View, compile and create the corresponding View Controller and navigation bar on it, and add it to the label bar controller. You need to implement the AppDelegate delegate to create a New Root View. First, import the name of the new view, especially the LinAppDelegate. h file.
# Import "LinFirstViewController. h" # import "LinSecondViewController. h" # import "LinThirdViewController. h" // delegate protocol proxy # import "LinAppDelegate. h"
Override-(void) viewDidLoad method:
-(Void) viewDidLoad {[super viewDidLoad]; // create a view object and the corresponding navigation bar object. Assume that both the navigation bar LinFirstViewController * pFirstVC = [[LinFirstViewController alloc] initWithNibName: nil bundle: nil]; UINavigationController * pFirstNavigation = [[UINavigationController alloc] Using: pFirstVC]; LinSecondViewController * using condvc = [[LinSecondViewController alloc] Using: nil bundle: nil]; UINavigationController * implements condnavigation = [[UINavigationController alloc] Using: Implements condvc]; LinThirdViewController * pThirdVC = [[LinThirdViewController alloc] Using: nil bundle: nil]; UINavigationController * direction = [[UINavigationController alloc] direction: pThirdVC]; // initialization array, storage navigation controller NSArray * array = [[NSArray alloc] direction: pFirstNavigation, direction condnavigation, direction, nil]; // initialize the label bar controller UITabBarController * pTabBar = [[UITabBarController alloc] init]; // set the View bar controller (array) pTabBar in the label bar. viewControllers = array; // call Method Based on the delegate Protocol [self goInNemView: pTabBar];} // construct the delegate protocol method and place the tag controller in the New Root View-(void) goInNemView :( id) sender {// obtain the current program UIApplication * app = [UIApplication sharedApplication]; // create the application's delegate object LinAppDelegate * pDelegate = app. delegate; // set the New Root View Controller and use the delegate method to implement the proxy pDelegate. window. rootViewController = sender ;}