ios - 弹出视图控制器在 Xcode 11.2.1 中打开后立即关闭
问题描述
通过使用以下方法调用弹出窗口
func annoucementdisplay()
{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let ivc = storyboard.instantiateViewController(withIdentifier: "PopUpViewController") as! PopUpViewController
ivc.modalTransitionStyle = .crossDissolve
ivc.modalPresentationStyle = .custom
let quiclvw = UIWindow(frame: UIScreen.main.bounds)
quiclvw.windowLevel = UIWindow.Level.alert
quiclvw.rootViewController = UIViewController()
quiclvw.makeKeyAndVisible()
let transition = CATransition()
transition.duration = 1.0
transition.type = CATransitionType.reveal
transition.subtype = CATransitionSubtype.fromBottom
quiclvw.layer.add(transition, forKey: kCATransition)
quiclvw.rootViewController?.present(ivc, animated: true, completion: nil)
}
它在 Xcode 10.3 中运行良好,但是当我在 Xcode 11.2.1 中运行我的代码时,弹出窗口即将到来,但它在打开后立即消失。
我试过了
ivc.modalPresentationStyle = .fullScreen
但它不起作用。
解决方案
我已经在我的 xCode 11.2 上运行了这段代码,它运行成功。
func annoucementdisplay()
{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let ivc = storyboard.instantiateViewController(withIdentifier: "PopUpViewController") as! PopUpViewController
ivc.modalTransitionStyle = .crossDissolve
ivc.modalPresentationStyle = .custom
let quiclvw = UIWindow(frame: UIScreen.main.bounds)
quiclvw.windowLevel = UIWindow.Level.alert
quiclvw.rootViewController = UIViewController()
quiclvw.makeKeyAndVisible()
let transition = CATransition()
transition.duration = 1.0
transition.type = CATransitionType.reveal
transition.subtype = CATransitionSubtype.fromBottom
quiclvw.layer.add(transition, forKey: kCATransition)
present(ivc, animated: true, completion: nil)
}
推荐阅读
- flutter - 我正在使用 Flutter 文本字段(不是文本表单字段)制作温度转换器应用程序我需要限制多个点和多个符号 (+ - )?
- go - 使用泛型:运算符 == 未为 T 定义
- python - 安装 Nashpy 库时缺少 requirements.txt
- java - Android:BLE清除取消自动连接
- python - django-admin 显示错误,我该如何解决?
- python - MSINT - 图像分类 - 值错误不兼容的形状
- git - ¡实时站点中的GITLAB和GIT存储库
- angular - 从 API 获取对象时如何强制对象的类?
- java - Toast 和 startActivity 在片段中工作,但不在类中
- python-3.x - TypeError:无法在 fastapi 中腌制“模块”对象