Andrew Lauer Barinov
Andrew Lauer Barinov

Reputation: 5754

Embedding an existing UINavigationController to new view controllers

Suppose I have a storyboard with a navigation controller and several view controllers.

All is well until I try to add a new view controller and would like to associate it with the existing UINavigationController. When I go to Editor>Embed>Navigation Controller, Xcode helpfully creates a new controller, which is precisely what I don't want. When I attempt to drag to create a wireframe, I create a segue relationship, which again is what I don't want.

Is there a way to make new view controllers play nice with an existing nav controller?

Upvotes: 2

Views: 3805

Answers (1)

Richard Venable
Richard Venable

Reputation: 8715

I think you are thinking of the UINavigationController incorrectly. UINavigationController is just a container view controller that manages a hierarchy of view controllers. You start with one UINavigationController, which has exactly one root view controller (it sounds like you want more than one, which isn't going to happen). When you push a new view controller, it is pushed onto the same UINavigationController. So if you want multiple view controllers associated with a single UINavigationController, they have to hierarchically stack onto the root view controller.

Upvotes: 5

Related Questions