0

If I have a storyboard with a navigationController with 2 child viewControllers (vcA and vcB) where vcA is set as the navigationController's root viewController and a storyboard segue connects vcA to vcB (vcA and vcB show alternate ways of viewing the same object).

Is it a reasonable design pattern (and if so how would I do it) to change the order of the child viewControllers in the navigation stack when the app starts dependent on the users preference. If a user prefers to view the object in the way it is presented in vcB, can I somehow override the order in the storyboard and make vcB the root viewController of the navigationController when the app starts. So if user preference is the the "vcB view", the navigationControllers order is navigationController -> vcB <-> vcA compared to normal where the navigationController's order is navigationController -> vcA <-> vcB.

Ideally I want to keep the use of the storyboard to help with navigation bar button configuration etc

If this is not possible or recommended, what is the recommended way to conditionally show users a different navigationController child viewController at app launch.

enter image description here

lozflan
  • 835
  • 10
  • 23

1 Answers1

0

You should be able to do this:

1) In addition to the segues shown in your image, create another Push segue from navController to vcB, and another Push sugue from vcA to vcB.

2) Use performSegue(withIdentifier: "segue_name", sender: self) to conditionally load vcA or vcB at the start.

3) Use performSegue in vcA and vcB to transition to each other based on the same conditions.

crperez
  • 130
  • 1
  • 10
  • Thx. I was also trying to understand if there are any other ramifications of doing this compared to following the laid out view controller heirachy done in the storyboard. If i go initing view controllers manually in different order to how its laid out in the storyboard are any other things affected ie state restoration complexity, navigation between the view controllers created in code, ability to use unwind segues etc – lozflan Jun 13 '18 at 21:12