如何使用导航控制器关闭两个viewcontroller?

问题描述 投票:-1回答:1

我有三个相关的视图,他们都连接到导航控制器,推送segues(我也存储了数组使用准备segue与所有三个)。所以我想使用dismiss,因为我不想更改viewcontrollers中使用的已存在的存储数组。

所以我在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 B中有一个错误,当Viewcontroller C上有更新内容时,所以临时解决方案就是转到A,然后重新加载tableview。

ios swift segue uistoryboardsegue dismissviewcontroller
1个回答
0
投票

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

或者,如果您更愿意使用segue,您可以perform an unwind segue,返回查看控制器A.

© www.soinside.com 2019 - 2024. All rights reserved.