Arnaud
Arnaud

Reputation: 17767

iOS storyboard: modal and push segue on the same viewcontroller

I have a sequence of ViewControllers (B, C, D, ...), children of a UINavigationController (A0), that you access sequentially (A0 -> B -> C -> D, ...).

I would also like to allow a UITableViewController A1 to access each ViewController individually without going through the whole sequence (so A1 -> B, or A1 -> C, A1 -> D).

In the storyboard, I tried to link B this way:

I started to add the A0 -> B push segue in the storyboard, which automatically added a Navigation Bar, that I customized with a title and buttons.

Then, I added the A1 -> B modal segue, and the Navigation Bar disappeared from the storyboard.

Now if I remove that 2nd segue, the navigation bar re-appears with the customization.

Is there something wrong with what I'm trying to achieve, or is it just a limitation of the storyboard ?

Thanks

Upvotes: 0

Views: 2643

Answers (1)

Anil Varghese
Anil Varghese

Reputation: 42977

The default navigation bar is comes with a navigation controller when you push a view controller to the navigation controller. When you connect

  1. A0-B, using a push segue, navigation bar will automatically come since it is pushed to a navigation controller.
  2. A1-B, using a modal segue, navigation bar disappears since it is not under a navigation controller.

So what you can do is add a navigation controller before A1 and push B. Or programmatically add a navigation bar after present it from A1. If you push from A0 bar will automatically come

Upvotes: 0

Related Questions