ios - Why doesn't my app return to my detail view when it's restored? -


my app has simple organization, i've configured in interface builder storyboard (not in code). there navigation view controller, has root view controller set main view controller. main view contains table, cells segue detail view controller.

when suspend application while looking @ detail view , resume it, i'm returned main view, rather detail view. why might be?

details:

i have set restoration ids in interface builder navigation view controller, main view controller , detail view controller. i've tried adding restoration id table view , making main view controller implement uidatasourcemodelassociation.

my app returning yes shouldrestoreapplicationstate , both main view , detail view have encode/decoderestorablestatewithcoder methods.

i'm testing suspend/resume using simulator: run app, navigate detail view, hit home button, , click stop button in xcode. resume, i'm running app again xcode.

i see following calls on suspend:

appdelegate shouldsaveapplicationstate mainviewcontroller encoderestorablestatewithcoder detailviewcontroller encoderestorablestatewithcoder 

and on resume:

appdelegate shouldrestoreapplicationstate appdelegate viewcontrollerwithrestorationidentifierpath navigation appdelegate viewcontrollerwithrestorationidentifierpath navigation/mainview mainviewcontroller viewdidload appdelegate viewcontrollerwithrestorationidentifierpath navigation/detailview mainviewcontroller decoderestorablestatewithcoder 

in addition wrong view being restored, there's else odd: why restoration identifier path detail view "navigation/detailview" , not "navigation/mainview/detailview"? there no direct relationship between navigation view controller , detail view controller. connection in interface builder via segue main view.

have misconfigured something?

i have tried assigning restoration class detail view. when restoration code invoked, fails because uistaterestorationviewcontrollerstoryboardkey not set in coder.

here's toy version of project replicates problem: https://github.com/wanderingstar/restorationtest

i'm trying xcode version 5.0 (5a1413) , ios simulator version 7.0 (463.9.4), in case relevant.

the answer turned out simple: not calling

[super encoderestorablestatewithcoder:coder]; 

in encoderestorablestatewithcoder:coder method in view controllers (and doing same in decode...).

this tutorial helped me step through each step of process, , find out i'd gone wrong: http://useyourloaf.com/blog/2013/05/21/state-preservation-and-restoration.html

also, turns out "navigation/detailview" what's expected. navigation view controller restores of views in stack , puts them stack, rather each view restoring later views in stack.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

javascript - Backbone.js getting target attribute -

html - Repeat image to extend header to fill screen -