导航控制器使用
创建
用xcode带的功能进行拖拽
- 拖拽Navigation Controller
- 或者选中原有的,点击上面的Editor-> embed in-> Navigation Controller
使用代码的方式,在AppDelegate.m中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 1. 创建一个现实的UIWindow,大小与屏幕一样
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
// 2. 创建一个显示的控制器,使用三种方式
UIViewController* vc;
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController * controll = [[UINavigationController alloc]initWithRootViewController:vc];
// 3. 将控制器与window关联
self.window.rootViewController = controll;