Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Những thông báo này là cơ hội để bạn thay đổi hành vi ứng dụng của bạn. Trong khi ứng dụng của bạn ở phía trước, hệ thống sẽ gửi sự kiện liên lạc với nó để chế biến. Cơ sở hạ tầng UIKit hầu hết các công việc khó khăn của việc cung cấp các sự kiện cho các đối tượng tùy chỉnh của bạn. | CHAPTER 3 App States and Multitasking It releases some other system-managed data caches. Returning to the Foreground Returning to the foreground is your app s chance to restart the tasks that it stopped when it moved to the background. The steps that occur when moving to the foreground are shown in Figure 3-6. The applicationWillEnterForeground method should undo anything that was done in your applicationDidEnterBackground method and the applicationDidBecomeActive method should continue to perform the same activation tasks that it would at launch time. Figure 3-6 Transitioning from the background to the foreground Managing App State Changes 2011-10-12 2011 Apple Inc. All Rights Reserved. 46 CHAPTER 3 App States and Multitasking Note The UIApplicationWillEnterForegroundNotification notification is also available for tracking when your app reenters the foreground. Objects in your app can use the default notification center to register for this notification. Processing Queued Notifications at Wakeup Time An app in the suspended state must be ready to handle any queued notifications when it returns to a foreground or background execution state. A suspended app does not execute any code and therefore cannot process notifications related to orientation changes time changes preferences changes and many others that would affect the app s appearance or state. To make sure these changes are not lost the system queues many relevant notifications and delivers them to the app as soon as it starts executing code again either in the foreground or background . To prevent your app from becoming overloaded with notifications when it resumes the system coalesces events and delivers a single notification of each relevant type that reflects the net change since your app was suspended. Table 3-2 lists the notifications that can be coalesced and delivered to your app. Most of these notifications are delivered directly to the registered observers. Some like those related to device .