Navigation stack will not be updated, segue from G

2019-08-24 07:40发布

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??

1条回答
趁早两清
2楼-- · 2019-08-24 08:13

Couple things:

  1. 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() or present().

  2. 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 pushed SearchVC onto the navigation stack. If SearchVC "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 of MainVC and trying to push it onto the stack.

查看更多
登录 后发表回答