[ad_1]
I need to create a navigation hierarchy the place I need to go to a SecondViewController from FirstViewController utilizing a NavigationController. The FirstViewController incorporates a button B that I intend to make use of to go to a SecondViewController. I’m using the navigation controller idea since I need to return to the FirstViewController later. I’ve carried out the next steps to realize it:
- I’ve embedded a NavigationController right into a storyboard X containing each the FirstViewController and SecondViewController.
- I’ve created a segue from the button B current within the FirstView (has FirstViewController related to it) to the SecondView (has SecondViewController).
- I set the navigationViewController nvc as following after I’ve introduced the firstViewController:
nvc = UINavigationController.init(rootViewController: firstViewController)
- 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 would not current itself even after pushing.
- 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 would not open even when I remark the performSegue code.
Could I ask what mistake I’m making right here?
[ad_2]
