gpt4 book ai didi

ios - 如何立即替换呈现的 UIViewController?

转载 作者:行者123 更新时间:2023-11-28 13:38:42 27 4
gpt4 key购买 nike

我实现了两个不同的 UIViewControllers,它们应该根据服务器响应和用户操作相互替换。为简单起见,假设我们有两个 UIViewControllersbutton 替换为另一个,这应该会触发此替换。

现在我需要替换那个部分,但问题是在关闭一个屏幕和显示另一个屏幕之间存在一些延迟。我想以某种方式摆脱它。我使用 present method 模态显示 UIViewController

我考虑将这两个屏幕作为 xib 文件中的 View ,以及一个将加载这些 xibsUIViewController,添加它们作为 subViews 并在需要时将一个 subView 替换为另一个,但也许有一种方法可以用两个 UIViewControllers 来做到这一点?

我用来呈现 Controller 的代码:

let vc = UIViewController1()
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: false, completion: nil)

并解雇:

self.dismiss(animated: false, completion: nil)

最佳答案

你可以添加一个容器 View ,在那个 View 中你可以简单地添加你想要的 Controller 作为 subview Controller official doc reference.

another reference

关于ios - 如何立即替换呈现的 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56304014/

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