Why isn't my navigation stack being preserved upon restoring the app?

余生长醉 提交于 2019-12-11 07:14:53

问题


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:

  1. Main.Storyboard - TempScreen (UIViewController)
  2. Navigation.Storyboard - SWRevealViewController
  3. Navigation.Storyboard - MenuTableViewController (rear view of SWRevealController)
  4. Navigation.Storyboard - Storyboard Reference to MyPlaces (front view of SWRevealController)
  5. MyPlaces.storyboard - Places, Initial View Controller
  6. MyPlaces.storyboard - Place Detail
  7. MyPlaces.storyboard - Storyboard reference to Interaction
  8. 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:

  1. TempScreen
  2. TempScreen, Navigation (the rear view for the SWRevealController)
  3. TempScreen, Navigation, menuTableViewController
  4. TempScreen, Navigation, MyPlacesNavController (init nav controller for MyPlaces.storyboard)
  5. TempScreen, Navigation, MyPlacesNavController, Places (VC)
  6. TempScreen, Navigation, MyPlacesNavController, Places (VC), PlaceDetail
  7. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!