1
votes

I have a UITabBarController which is connected to 3 UINavigationControllers. Each of these have a UIViewController as a root view controller. When I click on a button in one of these ViewControllers (VC1), I want it to segue to new ViewController (VC2). Simple enough.

During runtime, when the segue takes place and VC2 appears, the navigation bar disappears.

The navigation bar is present in the storyBoard / interface builder, and the segue is the type: present (Push).

Code in VC1:

@IBAction func create_clicked(_ sender: Any) {
    performSegue(withIdentifier: "segueIdentifier", sender: self)
}

It might help to know how the UITabBarController tabBar is instantiated:

func login() {

    let storyBoard = UIStoryBoard(name: "Main", bundle: nil)
    let tabBar = storyBoard.instantiateViewController(withIdentifier: "tabBar")

    window?.rootViewController = tabBar
}

Please help.

1
What type of segue are you using? - vacawama
Present (Push) segue - Legatro
Does the navigation bar show in the Storyboard for VC2? - vacawama
Yes: the navigation bar does show in the Storyboard for VC2 - Legatro
"present (Push)" That's meaningless. present and push are opposites. Which is it???? - matt

1 Answers

3
votes

After a great deal of experimentation, we determined that even though Interface Builder said this was a Show (Push) segue, and even though we were in a Navigation Controller to start with, it was behaving as a Present Modally segue.

So we changed the segue type, using the pop-up menu in Interface Builder, from Show (Push) to plain Push, even though that's deprecated — and the interface worked correctly.

And then we changed it back to Show (Push) and the interface continued to work correctly. Problem solved!

I suspect the storyboard was corrupted in some way. Obviously Interface Builder should not lie to you about what kind of segue this is, but basically, that is what it seems to have been doing.

EDIT The problem was caused, apparently, by making a Show Detail segue and changing it to Show. When you do that, it's still a Show Detail segue, which in this context behaves as a modal presentation. That's an Xcode bug! I reported it, and Apple now says this will be fixed in Xcode 9.3.