在Swift中,当我们使用present方法以FullScreen类型显示页面时,页面可能会黑屏。这通常是由于在显示新页面之前,旧页面没有正确地被移除导致的。

解决此问题的一种方法是在present方法之前确保正确地移除旧页面。你可以尝试使用以下代码来移除旧页面:

if let presentingViewController = presentingViewController {
    presentingViewController.dismiss(animated: false, completion: nil)
}

然后再使用present方法显示新页面:

let viewController = YourViewController()
viewController.modalPresentationStyle = .fullScreen
present(viewController, animated: true, completion: nil)

这样做可以确保在显示新页面之前正确地移除旧页面,从而避免页面黑屏的问题

swift中present页面使用FullScreen类型时页面会黑屏

原文地址: http://www.cveoy.top/t/topic/hLta 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录