问题
So as per my post here: Why is changing my app's orientation dismissing my parent view controller after state restoration? I had a discussion going with another user and we concluded that this issue has to do with my navigation stack not being restored.
Summary from that post - I can successfully modally present controllers from my restored VC, however, when I rotate the device orientation to display one of the modally presented view controllers then proceed to dismiss that controller, the app doesn't go back to the restored controller. If I don't rotate the screen, it works as expected.
All of my controllers are being instantiated via segues in Storyboards. All of the scenes are given restoration identifiers in their respective Storyboard. The VC I'm restoring is successfully being restored, however its no longer a part of a navigation stack (navigationController is coming out to be nil).
Here is my app's flow leading up to the last scene in which I'm restoring, where SWRevealController is a library I'm using for our app's sidebar:
- Main.Storyboard - TempScreen (UIViewController)
- Navigation.Storyboard - SWRevealViewController
- Navigation.Storyboard - MenuTableViewController (rear view of SWRevealController)
- Navigation.Storyboard - Storyboard Reference to MyPlaces (front view of SWRevealController)
- MyPlaces.storyboard - Places, Initial View Controller
- MyPlaces.storyboard - Place Detail
- MyPlaces.storyboard - Storyboard reference to Interaction
- Interaction.storyboard - CreateInteraction (this is the scene that is being restored where I'm having issues)
As you can see there's a lot of steps leading up to reaching the scene I am restoring. The scene I am restoring is reached via a Push segue from a button press.
While printing off the identifierComponents
within the viewControllerWithRestorationIdentifierPath
method in the AppDelegate
, I found something interesting. Here is what each iteration printed:
- TempScreen
- TempScreen, Navigation (the rear view for the SWRevealController)
- TempScreen, Navigation, menuTableViewController
- TempScreen, Navigation, MyPlacesNavController (init nav controller for MyPlaces.storyboard)
- TempScreen, Navigation, MyPlacesNavController, Places (VC)
- TempScreen, Navigation, MyPlacesNavController, Places (VC), PlaceDetail
- TempScreen, Navigation, MyPlacesNavController, Interaction <--- What happened to Places and PlaceDetail?
来源:https://stackoverflow.com/questions/45091417/why-isnt-my-navigation-stack-being-preserved-upon-restoring-the-app