Swift Storyboard Cross解散过渡闪烁不同的视图控制器

发布于 2025-01-25 17:10:10 字数 929 浏览 2 评论 0原文

我正在创建一个具有交叉溶解过渡的应用程序。当呈现视图控制器时,就会发生问题,并且每次交叉解散过渡发生直到应用程序被迫关闭并重新启动时,先前的屏幕闪烁一秒钟。许多视图控制器使用以下列出的代码以4种不同的方式显示。通过使用故事板的“显示”或“显示细节”链接到另一个视图控制器的按钮从一个视图控制器链接到另一个视图控制器,这些按钮不包含在下面的代码中。感谢提前的任何帮助!

代码:

方法1

DispatchQueue.main.async {
    let vc = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
    self.present(vc, animated: true, completion: nil)
}

方法2

    DispatchQueue.main.async { self.navigationController?.popViewController(animated: true)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let alert = storyboard.instantiateViewController(withIdentifier: "Alerts")
        alert.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
        alert.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
        self.present(alert, animated: true, completion: nil)
    }

I am creating an app with cross dissolve transitions. The issue occurs when a view controller is presented and a previous screen flashes for a split second every time a cross dissolve transition happens until the app is forced closed and restarted. A lot of the view controllers are displayed in 4 different ways using the code listed below. Some are changed using a button from one view controller linked to another view controller with using storyboard's "show" or "show detail" which is not included in the code below. Thanks for any help in advance!

Code:

METHOD 1

DispatchQueue.main.async {
    let vc = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
    self.present(vc, animated: true, completion: nil)
}

METHOD 2

    DispatchQueue.main.async { self.navigationController?.popViewController(animated: true)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let alert = storyboard.instantiateViewController(withIdentifier: "Alerts")
        alert.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
        alert.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
        self.present(alert, animated: true, completion: nil)
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文