Search code examples
iosswiftuiviewcontrolleruinavigationcontrollersegue

Push Segue triggers a Modal Segue that leads to VC with no navigation bar


My structure is:

ViewController A [-> (modal)] Navigation Controller -> ViewController B [-> (push)] ViewController C

In other words: VC A has a button you push to do a modal segue to VC B (which happens to be embedded in a Navigation Controller).

Then in VC B, you click on a table view cell and this triggers a push segue to VC C. All segues were made on the storyboard and identifiers were appropriately named.

The Issue is: When you click on the table view cell that transitions from VC B to VC C, the transition does correctly go to VC C, but it animates like a modal segue and VC C does not have a navigation bar (even when I specifically set navigationController?.isNavigationBarHidden = false). Thus, there is no back button.

For debugging purposes, I embedded VC A in a nav controller and had a button from there segue to a new VC with the push segue and the same thing happened (that thing being that the transition did not spawn the nav bar). Any ideas to solve this issue?

EDIT: Basic idea of the VC setup. Note that segue from VC A to VC B is done in code.

VC Setup


Solution

  • To fix this you need to connect the modal segue from VC A to VC B’s Navigation Controller.