当使用xib创建控制器时,一般会使用initWithNibName:方法进行实例化。
通过日志,可以发现此时调用如下方法:
2015-12-2417:56:18.232LifeCycle[15470:3839342]-[AppDelegateapplication:didFinishLaunchingWithOptions:]
2015-12-2417:56:18.232LifeCycle[15470:3839342]-[XibViewControllerinitWithNibName:bundle:]
2015-12-2417:56:18.235LifeCycle[15470:3839342]-[XibViewControllerloadView]
2015-12-2417:56:18.235LifeCycle[15470:3839342]-[XibViewControllerviewDidLoad]
2015-12-2417:56:18.236LifeCycle[15470:3839342]-[XibViewControllermyNibView]
2015-12-2417:56:18.239LifeCycle[15470:3839342]-[XibViewControllerviewWillAppear:]
2015-12-2417:56:18.241LifeCycle[15470:3839342]-[AppDelegateapplicationDidBecomeActive:]
2015-12-2417:56:18.243LifeCycle[15470:3839342]-[XibViewControllerviewWillLayoutSubviews]
2015-12-2417:56:18.251LifeCycle[15470:3839342]-[XibViewControllerviewDidLayoutSubviews]
2015-12-2417:56:18.253LifeCycle[15470:3839342]-[XibViewControllerviewWillLayoutSubviews]
2015-12-2417:56:18.253LifeCycle[15470:3839342]-[XibViewControllerviewDidLayoutSubviews]
2015-12-2417:56:18.258LifeCycle[15470:3839342]-[XibViewControllerviewDidA
当使用StroyBoard创建控制器时,程序在启动一开始,就会对StoryBoard文件进行读取,并且自动创建根控制器(即,带箭头的控制器),在创建过程中,会自动调用initWithCoder方法以及awakeFromNib方法。
通过日志,我们还可以发现,实例化根控制器是在didFinishLaunchingWithOptions:这个方法之前就进行了。
2015-12-2417:59:49.124LifeCycle[15490:3842901]-[SBViewController1initWithCoder:]
2015-12-2417:59:49.127LifeCycle[15490:3842901]-[SBViewController1awakeFromNib]
2015-12-2417:59:49.131LifeCycle[15490:3842901]-[AppDelegateapplication:didFinishLaunchingWithOptions:]
2015-12-2417:59:49.131LifeCycle[15490:3842901]-[SBViewController1loadView]
2015-12-2417:59:49.134LifeCycle[15490:3842901]-[SBViewController1viewDidLoad]
2015-12-2417:59:49.134LifeCycle[15490:3842901]-[SBViewController1viewWillAppear:]
2015-12-2417:59:49.136LifeCycle[15490:3842901]-[AppDelegateapplicationDidBecomeActive:]
2015-12-2417:59:49.139LifeCycle[15490:3842901]-[SBViewController1viewWillLayoutSubviews]
2015-12-2417:59:49.140LifeCycle[15490:3842901]-[SBViewController1viewDidLayoutSubviews]
2015-12-2417:59:49.143LifeCycle[15490:3842901]-[SBViewController1viewDidAppear:]
网友评论