重新过一遍App生命周期

●启动App

1、application:didFinishLaunchingWithOptions:
2、viewDidLoad
3、viewWillAppear
4、viewWillLayoutSubviews
5、viewDidLayoutSubviews
6、viewDidAppear
7、applicationDidBecomeActive

笔记:
a. App加载 → 根视图控制器加载 → App活跃
b. 注意:App活跃是发生在根视图控制器DidAppear之后的
c. 注意:在App的启动过程中没有"将要进入前
台"(applicationWillEnterForeground )这个步骤

● 点击APP桌面图标,app进入前台

 1. applicationWillEnterForeground
 2. applicationDidBecomeActive

笔记:
a.顺序是:App将要进入前台→App活跃
b. 跟App进入后台一样,在此过程中,ViewController不参与
其中,在屏幕上出现的ViewController不会调用"视图控制器
将要显示"(viewWillAppear) 和 "视图控制器已经显示"
(viewDidAppear)

●单击Home键,App进入后台

 1.  applicationWillResignActive
 2. applicationDidEnterBackground

笔记:
a. 整体顺序是:App将不活跃 → App进入后台
b. 注意:在App进入后台的过程中,ViewController是不参 > 与其中
的,也就是说当前屏幕上显示的ViewController并不会调用 > 视图
控制器将要消失(viewWillDisappear) 和 视图控制器已经 > 消失
(viewDidDisappear)

●App锁屏

  1.  applicationWillResignActive
  2. applicationDidEnterBackground

笔记:
a. App锁屏操作所产生的生命周期跟app进入后台是相同的

●App解锁

 1. applicationWillEnterForeground
 2. applicationDidBecomeActive

笔记:
a.App解锁操作所产生的生命周期跟App进入前台是相同的

●App销毁

  1.  applicationWillResignActive
  2.  applicationDidEnterBackground
  3.  applicationWillTerminate

笔记:
a. 整体顺序是:App将不活跃 → App进入后台 → App将要销毁
b. 注意:这个过程ViewController同样是不参与的

●双击Home键,由App进入App卡片列表

1. applicationWillResignActive

笔记:
a.在App进入App卡片列表的过程中,仅有一步被调用:App将不
活跃(applicationWillResignActive)
b.注意:如果此时,用户在App卡片列表中选择了其他App,接下
来会调用:App进入后台(applicationDidEnterBackground)
c.注意:如果此时,用户点击Home键,App由App卡片列表重新
回到前台,接下来会调用:App活跃
(applicationDidBecomeActive),要注意的是在这个过程中并
不会调用App将要进入前台
(applicationWillEnterForeground)

●ViewController1 PushTo / PresentTo ViewController2

  1.  -----VC2----- viewDidLoad
  2. -----VC1----- viewWillDisappear
  3. -----VC2----- viewWillAppear
  4. -----VC2----- viewWillLayoutSubviews
  5. -----VC2----- viewDidLayoutSubviews
  6. -----VC2----- viewDidAppear
  7. -----VC1----- viewDidDisappear
  8. -----VC1----- presentViewCompleted  (optional)
   [self dismissViewControllerAnimated:YES completion:^{
         NSLog(@"dismissViewControllerCompleted");
     }];

●ViewController2 PopTo / DismissTo ViewController1

   1.  -----VC2----- viewWillDisappear
   2.  -----VC1----- viewWillAppear
   3.  -----VC1----- viewDidAppear
   4.  -----VC2----- viewDidDisappear
   5.  -----VC2----- dismissViewControllerCompleted  (optional)
   [self dismissViewControllerAnimated:YES completion:^{ 
         NSLog(@"dismissViewControllerCompleted"); 
     }];
   6.  -----vc2----- dealloc

你可能感兴趣的:(重新过一遍App生命周期)