gpt4 book ai didi

ios - 在没有动画的情况下一次关闭两个 UIViewController

转载 作者:可可西里 更新时间:2023-11-01 01:07:58 25 4
gpt4 key购买 nike

我有一堆 UIViewController,如 A -> B -> C。我想从 C 返回到 Controller A。我正在使用以下代码进行操作:

DispatchQueue.global(qos: .background).sync {
// Background Thread
DispatchQueue.main.async {
self.presentingViewController?.presentingViewController?.dismiss(animated: false, completion: {
})}
}

尽管我将 animated 设置为 false,但可以在屏幕上看到 Controller B。如何在不显示中间一个 (B) 的情况下关闭两个 UIViewControllers?

P.S: 我不能直接从根 Controller 中解雇,也不能使用 UINavigationController

我搜索了社区,但找不到有关该动画的任何信息。

Dismiss more than one view controller simultaneously

最佳答案

试试这个。

self.presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)

像这样创建了一个示例 Storyboard

enter image description here

黄色 View Controller 是ViewController类型,按钮 Action 如下

@IBAction func Pressed(_ sender: Any) {
self.presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)
}

输出

enter image description here

关于ios - 在没有动画的情况下一次关闭两个 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53536852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com