通过Xib加载控制器的View
1.创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
2.设置窗口根控制器
2.1从XIB当中加载控制器.
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"VC" bundle:nil];
self.window.rootViewController = vc;
3.显示窗口
[self.window makeKeyAndVisible];
1.创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
2.设置窗口的根控制器.
2.1从Xib当中加载控制器.
initWithNibName:如果指定了名称,那么它就会去加载指定名称的Xib.
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"VC" bundle:nil];
如果没有指定名称.指定为nil,那么它就会去先加载跟它相同名称的Xib.
如果没有跟它相同名称的Xib,那么它就会再去加载跟它相同名称去点Controller的名字的Xib.
MyViewController *vc = [[MyViewController alloc] initWithNibName:nil bundle:nil];
控制器的init方法会调用initWithNibName:方法.
MyViewController *vc = [[MyViewControlleralloc] init];
self.window.rootViewController = vc;
3.显示窗口
[self.window makeKeyAndVisible];