I'm having issue with segue to the existing UIViewcontroller
via the pushViewController.
When I'm tap on the place in resultsViewController, I expect the segue to the MainVC, but i have an error:
pushViewController:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated.
How can I fix this, and have the transition to MainVC??
Couple things:
Make sure you are not "doubling up" on navigation. If you use a Segue to transition to another view controller, do not also call
.pushViewController()
orpresent()
.Understand the difference between push and present.
In your case, it appears (based on your description and your screenshot) that
MainVC
is the root VC of your NavController, and a Segue has pushedSearchVC
onto the navigation stack. IfSearchVC
"slides in from the right" that is almost certainly the case.If you have pushed a VC onto the Nav Stack, then you want to pop it off the stack with
popViewController(animated: Bool)
. That will "slide the previous VC back in from the left".In your
goToVc()
function, you are creating a new instance ofMainVC
and trying to push it onto the stack.