如何创建一个控制器
1 通过storyboard创建
加载storyboard
UIStoryboard *storyboard =[UIStoryboard storyboardWithName:@"name" bundle:nil];
创建storyboard 里面的控制器
UIViewController *vc=[storyboard instantiateInitialViewController];
self.window.rootViewController =vc;
Storyboard中有个属性叫 storyboardID 利用storyboardID可以加载控制器
UIViewController *vc=[storyboard instantiateViewControllerWithIdentifier:@"storyboardID "];
self.window.rootViewController =vc;
ViewController *dxt=[[ViewController alloc] init];
3制定xib文件来创建
ViewController *dxt=[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
将Storyboard设置为mainstoryboard AppeDelegate会自动做三件事
1 创建window
self.window=[[UIWindow alloc] initWithFram:[UIScreen mainScreen].bounds];
2加载storyboard,并且创建初始化控制器(箭头所指的控制器)
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController=[storyboard instantiateInitialViewController];
3显示窗口
[self.window makeKeyVisible];