4

On my story board I have a collection view controller embedded in a navigation controller. Now from the cell of the collection view, I programaticly open the second view controller (called TwoPicsViewController), like this:

 let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

            let nextViewController = storyBoard.instantiateViewController(withIdentifier: "TwoPicsViewController") as! TwoPicsViewController


            self.present(nextViewController, animated:true, completion:nil)

However when my TwoPicsViewController opens, I don't see the navigation bar at all. On the story board I connected the TwoPicsViewController to the first view controller with a segue show.

Am I missing something else?

Thanks

ios234975
  • 267
  • 1
  • 2
  • 7

2 Answers2

4

To push a new UIViewController to the navigation stack you should use:

self.navigationController?.pushViewController(nextViewController, animated: true)

Instead of:

self.present(nextViewController, animated:true, completion:nil)
Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
0

You are not putting the new vc on the navigation stack, try this:

performSegue(withIdentifier: "Segue Name", sender: nil)

And on Storyboard select the Segue, attributes inspector, identifier = "Segue Name"

JP Aquino
  • 3,946
  • 1
  • 23
  • 25