ios – Lacking transition from first view controller to second view controller utilizing navigation controller

[ad_1]

I wish to create a navigation hierarchy the place I wish to go to a SecondViewController from FirstViewController utilizing a NavigationController. The FirstViewController accommodates a button B that I intend to make use of to go to a SecondViewController. I’m using the navigation controller idea since I wish to return to the FirstViewController later. I’ve executed the next steps to realize it:

  1. I’ve embedded a NavigationController right into a storyboard X containing each the FirstViewController and SecondViewController.
  2. I’ve created a segue from the button B current within the FirstView (has FirstViewController related to it) to the SecondView (has SecondViewController).
  3. I set the navigationViewController nvc as following after I’ve offered the firstViewController:
nvc = UINavigationController.init(rootViewController: firstViewController)
  1. In a while, when the button B will get pressed, I execute the next code to push the secondViewController onto the navigation hierarchy:
self.nvc?.pushViewController(secondViewController, animated: true)

Nonetheless, the secondView does not current itself even after pushing.

  1. I’ve named the segue between the button B and secondViewController as kSegue, so I attempted to carry out the segue as an addition to see if the secondViewController presents itself or not:
self.performSegue(withIdentifier: "kSegue", sender: self)

An exception happens when each the 4th and fifth steps are carried out collectively. The exception states that I am pushing a viewController that already exists on the navigation hierarchy, however the second view nonetheless does not open even when I remark the performSegue code.

Might I ask what mistake I’m making right here?

[ad_2]

Leave a Reply