iOS UIViewController的生命周期

控制器 ViewController 绑定了storyBoard,控制器 ViewController2 未绑定storyBoard

  1. 控制器 ViewController present方式弹出控制器 ViewController2
-[ViewController initWithCoder:] (如果绑定了storyBoard走这个方法)
-[ViewController awakeFromNib] (xib 加载 完成)
-[ViewController loadView]
-[ViewController viewDidLoad]
-[ViewController viewWillAppear:]
-[ViewController viewWillLayoutSubviews]
-[ViewController viewDidLayoutSubviews]
-[ViewController viewDidAppear:]
-[ViewController touchesBegan:withEvent:] present ViewController2
-[ViewController2 initWithNibName:bundle:] (如果未绑定storyBoard走这个方法)
-[ViewController2 loadView]
-[ViewController2 viewDidLoad]
-[ViewController2 viewWillAppear:]
-[ViewController2 viewWillLayoutSubviews]
-[ViewController2 viewDidLayoutSubviews]
-[ViewController2 viewWillLayoutSubviews]
-[ViewController2 viewDidLayoutSubviews]
-[ViewController2 viewDidAppear:]
-[ViewController2 touchesBegan:withEvent:] dismiss ViewController2
-[ViewController2 viewWillDisappear:]
-[ViewController2 viewDidDisappear:]
-[ViewController2 dealloc]  
  1. 控制器 ViewController push方式进入控制器 ViewController2
-[ViewController initWithCoder:] (如果绑定了storyBoard走这个方法)
-[ViewController awakeFromNib] (xib 加载 完成)
-[ViewController loadView]
-[ViewController viewDidLoad]
-[ViewController viewWillAppear:]
-[ViewController viewWillLayoutSubviews]
-[ViewController viewDidLayoutSubviews]
-[ViewController viewDidAppear:]
-[ViewController touchesBegan:withEvent:] push ViewController2
-[ViewController2 initWithNibName:bundle:] (如果未绑定storyBoard走这个方法)
-[ViewController2 loadView]
-[ViewController2 viewDidLoad]
-[ViewController viewWillDisappear:]
-[ViewController2 viewWillAppear:]
-[ViewController2 viewWillLayoutSubviews]
-[ViewController2 viewDidLayoutSubviews]
-[ViewController viewDidDisappear:]
-[ViewController2 viewDidAppear:]
-[ViewController2 touchesBegan:withEvent:] pop ViewController2
-[ViewController2 viewWillDisappear:]
-[ViewController viewWillAppear:]
-[ViewController2 viewDidDisappear:]
-[ViewController viewDidAppear:]
-[ViewController2 dealloc]

推荐阅读更多精彩内容