Search code examples
iosswiftuiviewcontrolleruistoryboardseguexcode9

Swift StoryBoard Reference segue to Navigation controller not Root


Is there a way to use storyboard reference segue to a controller which is the second controller inside a navigation controller?

To be more specific: I have a cameraViewController in storyboard A. I would like to create a segue (with a storyboard reference) to storyboard B. In storyboard B i have a navigation controller with two controller. The segue should be from storyboard A (cameraViewController) to storyboard B (SecondViewController). If in the reference I use the StoryBoard reference of the controller the navigation bar is not displayed. And if I use the Storyboard ID of the navigatin controller, well the segue is to root controller. StoryBoard A StoryBoard A

Thank you.


Solution

  • In your Storyboard, a particular View Controller can be linked to more than one navigation structure.

    So, you can have Controller B as part of more than one Navigation Controller.

    In Storyboard "SB_A" create a segue to Storyboard "SB_B", but instead of segueing to the "default" VC in SB_B, segue to the VC identified as "FromSBA" - in this case, "FromSBA" is a 2nd Navigation Controller inside SB_B, whose root VC is Controller B.

    enter image description here

    enter image description here