先推荐ios 必读文章 App Programming Guide for iOS ,请在苹果官网搜索,并仔细阅读所有内容

State

Description

Not running

The app has not been launched or was running but was terminated by the system.

Inactive

The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.

Active

The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background

The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see Background Execution.

Suspended

The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code.

When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

注意这个图,程序进入background或者挂起了或者停止后,再次active前一定会经过inactive状态!

UIApplication.sharedApplication().applicationState 是UIApplicationState 类型,关于这个类型的说明如下:

An app may be active, inactive, or running in the background. You can use the value in this property to determine which of these states the app is currently in.

这里提到了应用程序运行中的3种状态,所以没有包含Not running 和 suspended 2个状态。

这里举一个inactive的状态的例子:

程序退到后台后,收到UILocalNotification ,点击通知消息对程序进行唤醒,调用

didReceiveLocalNotification方法时,得到的是UIApplicationState.Inactive状态。

最新文章

  1. 模态视图的modalTransitionStyle、modalPresentationStyle
  2. UICollectionView [NSIndexPath section]: message sent to deallocated instance
  3. Android在OnCreate中获取控件的宽度和高度
  4. NVIDIA显卡设置提升MineCraft流畅度
  5. 基于shiro授权过程
  6. Eclipse 导入项目乱码问题(中文乱码)
  7. 关于JavaScript中计算精度丢失的问题
  8. jsp容易混淆的知识点
  9. nodejs-ORM 操作数据库中间件waterline的使用
  10. OC和JS的交互
  11. UVa 12186 树形dp
  12. 百度APP爬虫
  13. Appium1.6 定位iOS元素和操作元素
  14. grep用法详解:grep与正则表达式
  15. URAL-1019 Line Painting----暴力或线段树
  16. GO-指针与函数
  17. Spring Boot构建RESTful API
  18. 模糊搜索框(H5),兼容安卓和ios(令人头大的ios输入法)
  19. ZeroMQ——一个轻量级的消息通信组件
  20. Django框架 之 form组件的钩子

热门文章

  1. 跳出iframe
  2. Java Programming Test Question 4
  3. 如何删除git远程分支
  4. standford工具-parser
  5. PHP弹出提示框并跳转到新页面即重定向到新页面
  6. gdb调试core文件
  7. 大数据之Ganglia
  8. 重读C#委托、事件有感
  9. Swift3.0P1 语法指南——基本操作符
  10. Java之异常处理机制