gpt4 book ai didi

ios - 无论 IOS 13 中的 View 层次结构如何,都将 ViewController 呈现在所有内容之上

转载 作者:行者123 更新时间:2023-11-28 05:37:08 28 4
gpt4 key购买 nike

在 iOS 13 中,模态视图 Controller 在呈现时有一个新行为。现在默认情况下它不是全屏,当我尝试将 modalPresentationStyle 更改为 .fullScreen 我的 View 显示并立即关闭。我正在用代码呈现 View Controller :

 if #available(iOS 13.0, *) {

var popupWindow: UIWindow?

let windowScene = UIApplication.shared
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.first
if let windowScene = windowScene as? UIWindowScene {
popupWindow = UIWindow(windowScene: windowScene)
}

let vc = UIViewController()
vc.view.frame = UIScreen.main.bounds

popupWindow?.frame = UIScreen.main.bounds
popupWindow?.backgroundColor = .clear
popupWindow?.windowLevel = UIWindow.Level.statusBar + 1
popupWindow?.rootViewController = vc
popupWindow?.makeKeyAndVisible()
popupWindow?.rootViewController?.present(self, animated: true, completion: nil)
}

最佳答案

我找到了解决方案:

if #available(iOS 13.0, *) {
if var topController = UIApplication.shared.keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
self.modalPresentationStyle = .fullScreen
topController.present(self, animated: true, completion: nil)
}

关于ios - 无论 IOS 13 中的 View 层次结构如何,都将 ViewController 呈现在所有内容之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58296552/

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