Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's possible to directly manipulate the view controller stack, independently of the application's segues or storyboards.</p> <p>You can use this technique to restore a deep stack of view controllers, and perform / animate just a single segue to the top view controller. (You will likely need to create a specific push segue for this purpose.)</p> <p>For example, to restore a two view controller stack, you could do the following. In this example, it's assumed that some action on an existing view controller leads to the state restore, but you can just as easily perform it from your App Delegate.</p> <pre><code>[self performSegueWithIdentifier:@"Page2Express" sender:self]; - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"Page2Express"]) { // Get any state data you need to from Core Data CoreDataType *valuePulledFromCoreData = // ... // Set up the page 2 view controller as you normally would Page2ViewController *page2ViewController = segue.destinationViewController; page2ViewController.instanceVariable = valuePulledFromCoreData; // Create a loose, page 1 view controller and set it up as required UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; Page1ViewController *page1ViewController = [storyboard instantiateViewControllerWithIdentifier:@"Page1ViewController"]; // Ensure you have this identifier set up in your storyboard page1ViewController.instanceVariable = valuePulledFromCoreData; // Add the page 1 view controller to the top of the navigation stack (to be later obscured in the segue by the page 2 view controller) NSMutableArray *viewControllers = [[self navigationController].viewControllers mutableCopy]; [viewControllers addObject:page1ViewController]; [self navigationController].viewControllers = viewControllers; } } </code></pre> <p>If, instead, you prefer to have no animations, then it's easier still. You can restore state solely by manipulating the view controller stack (and without using any segues) from <code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions</code> and <code>- (void)applicationWillEnterForeground:(UIApplication *)application</code>.</p> <p>Either way will work seamlessly and in tandem with your existing storyboard(s) and segues.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload