As far as i know,if we want to show the UIWindow, we need to do following steps:
- create UIWindow
- load mian.storyboard and instantiate view controller
- set the controller to UIWindow's root viewcontroller, then make UIWindow show
which looks like the following code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//创建窗口对象
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
//创建窗口的根控制器,并且赋值
UIViewController *rootVc = [[UIViewController alloc]init];
self.window.rootViewController = rootVc;
//显示窗口
[self.window makeKeyAndVisible];
return YES;
}
or init with storyboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIStoryboard *stroyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [stroyboard instantiateInitialViewController];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
But in the template, i don't see those code, is there something i neglected?