State Restoration of Child View Controllers
Last Revision: | Version 1.1, 2013-09-05 UIWindow's makeKeyAndVisible now called in willFinishLaunchingWithOptions. (Full Revision History) |
Build Requirements: | iOS 6.0 SDK or later |
Runtime Requirements: | iOS 6.0 or later, Automatic Reference Counting (ARC) |
Demonstrates how to implement "State Preservation and Restoration" in an app with child view controllers. The sample contains one parent view controller, which can host two different child view controllers. The user taps the segmented control to toggle between the two different children.
It shows how to preserve and restore the "current" child view controller. It encodes/decodes the segmented control state to decide which child to make visible. When the app is re-launched, it decodes the segmented control state as well as each child view, and properly adds the correct child to its parent. To make this all work properly, the parent view controller needs to encode/decode both children. In addition, to round out the sample, each child view controller restores it's text field state. The parent and both children are required to have restoration identifiers.
Copyright © 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-09-05