1 建立UIWindow //一個應用程式隻有一個UIWindow
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
讓UIWindow顯示出來(讓視窗成為主視窗 并且顯示出來)
[self.window makeKeyAndVisible];
2 建立控制器
JMViewController *vc = [[JMViewController alloc] init];
2.1第一種建立方式
NJViewController *vc = [[NJViewController alloc] init];
vc.view.backgroundColor = [UIColor redColor];
2.2第二種建立方式
NJViewController *vc = [[NJViewController alloc] init];
// 加載UIStoryboard(注意:僅僅是加載名稱叫做Test的storyboard, 并不會建立storyboard重的控制器以及控件)
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Test" bundle:nil];
// 建立storyboard中箭頭指向的控制器
NJViewController *vc = [storyboard instantiateInitialViewController];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"two"];
2.3第三種建立方式
NJViewController *vc = [[NJViewController alloc] initWithNibName:@"One" bundle:nil];
self.window.rootViewController = vc;
3.讓UIWindow顯示出來
[self.window makeKeyAndVisible];
return YES;