现有的过渡或演示正在发生; 导航堆栈不会更新

Sid*_*ake 21 ios swift

我遇到过这个警告:

pushViewController:animated:在发生现有转换或演示时调用; 导航堆栈不会更新.

在尝试navigationController?.popViewControllerAnimated(false)UIAlertController完成块调用时.

Ida*_*dan 22

此警告表示您正在尝试UINavigationController错误地使用:

pushViewController:animated:在发生现有转换或演示时调用; 导航堆栈不会更新

你在你所想的评论中提到popViewController使用

navigationController?.popViewControllerAnimated(false)
Run Code Online (Sandbox Code Playgroud)

内部完成块UIAlertController.因此,您试图从错误的视图中展开,UIAlertController不是UINavigationController堆栈的一部分.

尝试并关闭第UIAlertController一个,然后弹出当前ViewController.换句话说,popcompletion块中删除并将其放入OK块中.或unwind在警报前使用segue.

另一种可能性是,你有一个未使用或相同的副本storyboard.因此,如果按钮unwinding触发操作storyboard,请选择此按钮并检查connectivity inspector并删除不需要的连接.

例如:在我的情况下,标记的红色x是不必要的. 例

  • 完善.很容易忘记警报是视图控制器. (2认同)

Meg*_*iya 15

我使用DispatchQueue.main.async解决了这个问题.在UIAlertController的Transition完成后调用popviewcontroller

1)显示警报

2)延迟后调用pop viewcontroller

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
    self.navigationController?.popToRootViewController(animated: true)
}
Run Code Online (Sandbox Code Playgroud)

这不是最好的方法,但它有效!