创建控制器的几种方式
1 通过nib方式
// bundle:nil参数传nil,指的是从mainbundle中加载,mainbundle中包含项目中所有的资源 MJThreeViewController *three = [[MJThreeViewController alloc] initWithNibName:@"MJThree5345" bundle:nil]; self.window.rootViewController = three;
2 通过代码的方式
// 根据代码创建控制器 UIViewController *vc = [[UIViewController alloc]init]; vc.view.backgroundColor = [UIColor blueColor]; self.window.rootViewController = vc;
3 根据storyboard创建控制器
// 根据storyboard创建控制器 UIStoryboard *board = [UIStoryboard storyboardWithName:@"one" bundle:nil]; UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"myredview"]; self.window.rootViewController = vc;