导航堆栈不会更新,来自 GMSAutocompleteResultsViewController [英] Navigation stack will not be updated, segue from GMSAutocompleteResultsViewController
问题描述
我在通过 pushViewController 转到现有 UIViewcontroller
时遇到问题.
I'm having issue with segue to the existing UIViewcontroller
via the pushViewController.
当我点击 resultsViewController 中的位置时,我希望转到 MainVC,但出现错误:
When I'm tap on the place in resultsViewController, I expect the segue to the MainVC, but i have an error:
pushViewController:animated:在现有的过渡或演示发生时调用;导航堆栈不会更新.
我该如何解决这个问题,并过渡到 MainVC??
How can I fix this, and have the transition to MainVC??
推荐答案
两件事:
确保您没有在导航上加倍".如果您使用 Segue 转换到另一个视图控制器,请不要也调用
.pushViewController()
或present()代码>.
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()
.
了解推送和呈现之间的区别.
在您的情况下,MainVC
似乎是您的 NavController 的根 VC,并且 Segue 已推送 SearchVC
到导航堆栈.如果 SearchVC
从右侧滑入",那几乎肯定是这种情况.
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.
如果您已推送一个 VC 到导航堆栈上,那么您希望使用 popViewController(animated: Bool)
弹出>.这将将前一个 VC 从左侧滑回".
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".
在您的 goToVc()
函数中,您正在创建 MainVC
的 new 实例并尝试将其压入堆栈.
In your goToVc()
function, you are creating a new instance of MainVC
and trying to push it onto the stack.
这篇关于导航堆栈不会更新,来自 GMSAutocompleteResultsViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!