在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法里边操作
1,纯代码的方式
ViewController *VC = [storyboard instantiateInitialViewController];
ViewController *VC = [[ViewController alloc] init];
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:VC];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = naviVC;
[self.window makeKeyAndVisible];
纯代码创建VC的方式ViewControllerWith *vc = [[ViewControllerWith alloc] init];方法调用顺序:
init
initWithNibName:bundle: - 加载带有xib的控制器(默认ViewController)
loadView - 加载控制器视图
viewDidLoad - 加载完毕
2,通过Storyboard
1,创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
2,加载main.storyboard