我的共享资源: /ls/kevinkitty/
App States and Multitasking - 应用程序状态及多任务
For iOS apps, it is crucial to know whether your app is running in the
foreground or the background. Because resources are more limited on iOS
devices, an app must behave differently in the background than in the
foreground. The operating system also limits what your app can do in the
background in order to improve battery life and to improve the user’s
experience with the foreground app. The operating system notifies your app
whenever it moves between the foreground and background. These
notifications are your chance to modify your app’s behavior.
对于 iOS应用程序来说,了解程序当前正运行于后台或者前台是很重要的。因为 iOS设备
上的资源有限,应用程序处于后台时的行为必定要与处于前台时不同。为延长电池使用
时间以及提升前台应用程序的用户体验,操作系统也限制了应用程序处于后台时可做的
事情。在前台和后台切换的过程中,操作系统会通知你的应用程序,利用这些通知你可
以适时地改变应用程序的行为。
While your app is in the foreground, the system sends touch events to it for
processing. The UIKit infrastructure does most of the hard work of delivering
events to your custom objects. All you have to do is override methods in the
appropriate objects to process those events. For controls, UIKit simplifies
things even further by handling the touch events for you and calling your
custom code only when something interesting happens, such as when the
value of a text field changes.
当应用程序处于前台时,系统会分发触摸事件给它处理。 UIKit作为基础设施,承担了分
派事件这⼀工作中最难的部分,而你所要做的是在合适的对象中重写⼀些方法用以处理
这些事件。对于控件来说, UIKit更进⼀步,只有在⼀些特定的事件发生时才会去调用你
自定义的处理代码,比如某个文本域的值发生变化,否则它会自行处理好触摸事件。
As you implement your app, follow these guidelines:
(Required) Respond appropriately to the state transitions that occur. Not
handling these transitions properly can lead to data loss and a bad user
experience. For a summary of how to respond to state transitions, see
“Managing App State Changes”.
(Required) When moving to the background, make sure your app adjusts its
behavior appropriately. For guidelines about what to do when your app moves
to the background, see “Being a Responsible Background App”
iPhone应用程序编程指南--应用程序状态管理 来自淘豆网m.daumloan.com转载请标明出处.