Documentation URL

https://developer.apple.com/documentation/uikit/core_app/managing_your_app_s_life_cycle?language=objc

APP生命周期状态

应用的生命周期_第1张图片

管理生命周期事件

https://developer.apple.com/documentation/uikit/core_app/managing_your_app_s_life_cycle?language=objc

  • Launch

    初始化APP准备启动;

    • APP启动时序
      应用的生命周期_第2张图片
    • 执行一次APP配置
  • Activation

    APP显示到前台

    • 准备
      • [ApplicationDelegate applicationDidBecomeActive:]

        当APP处于active状态时,回调

      • [ApplicationDelegate applicationWillEnterForeground:]

        如果APP已经处于background,怎会先调用该方法,之后再回调applicationDidBecomeActive:方法;

      • [ViewController viewWillAppear:]

        更新视图内容

      • [ViewController viewDidAppear:]

        在视图出现在屏幕上后回调;

  • Deactivation

    APP处于background,被阻塞;

    • [ApplicationDelegate applicationWillResignActive:]

      首先调用该方法 ;在该过程中会中断app操作和保存用户关键数据;

    • [ApplicationDelegate applicationDidEnterBackground:]

      APP进入background回调该方法;

  • Background execution
  • Termination