用代码创建UINavigationController

1. 设置UIWindow的根视图为导航控制器

//  CZAppDelegate.m

//  03-UINav

//  Created by apple on 08/07/14.

//  Copyright (c) 2014年itcast. All rights reserved.

#import"CZAppDelegate.h"

#import"CZOneViewController.h"

@implementationCZAppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

{

self.window= [[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];

self.window.backgroundColor= [UIColorwhiteColor];

// 1.实例化导航控制器

CZOneViewController*one = [[CZOneViewControlleralloc]init];

UINavigationController*nav = [[UINavigationControlleralloc]initWithRootViewController:one];

nav.view.backgroundColor= [UIColorredColor];

NSLog(@"=== %@", nav);

self.window.rootViewController= nav;

[self.windowmakeKeyAndVisible];

returnYES;

}

你可能感兴趣的:(用代码创建UINavigationController)