视图控制器用来创建并且管理新的View,我们一般可以通过三种方式来创建UIViewController:
①通过代码来创建
- ViewController *viewController = [[ViewController alloc]init];
- viewController.view.backgroundColor = [UIColor blueColor];
②通过UIStoryboard来创建
1.首先要创建UIStoryboard,并且写上UIStoryboard的ID
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
- UIViewController *viewControllerTwo = [storyboard instantiateViewControllerWithIdentifier:@"Test"];
③通过xib来创建
1.创建Cocoa Touch并且勾选xib.
2.添加如下代码:
- ViewControllerThree *threeViewControll = [[ViewControllerThree alloc]initWithNibName:@"ViewControllerThree" bundle:nil];
- self.window.rootViewController = th