-1

我有三个相关的视图,它们都连接到导航控制器,带有推送序列(我也使用 prepare for segue 存储了所有三个数组)。所以我想使用dismiss,因为我不想更改视图控制器中使用的已经存在的存储数组。

所以我在 viewcontroller C ,我试图回到 A。

在此之前我一直使用self.dismiss(animated: true, completion: nil)这在关闭视图 B 时效果很好,但我想去 A。

我也尝试过使用:

let presentingViewController = self.presentingViewController
presentingViewController?.presentingViewController?.presentingViewController?.dismiss(animated: false, completion: nil)

但是,这不起作用,并产生此错误:

pushViewController:animated:在现有过渡或演示发生时调用;导航堆栈将不会更新。

有什么解决办法吗?

我想去viewcontroller A的原因是因为在Viewcontroller C上更新某些东西时Viewcontroller B中有一个错误,所以临时的解决方案是去A,然后重新加载tableview。

4

1 回答 1

0

调用setViewControllers(_:animated:)导航控制器,传入一个仅包含视图控制器 A 的数组。由于视图控制器 A 已经在堆栈中,因此动画将弹出。

或者,如果您更愿意使用 segue,您可以执行 unwind segue,返回查看控制器 A。

于 2019-03-13T19:59:35.850 回答