"Swift中页面黑屏问题:FullScreen模式下的Present方法修复"\n\n当使用Swift的present方法以FullScreen类型显示页面时,可能会出现黑屏问题。这通常是由于在显示新页面之前,旧页面没有正确地被移除导致的。\n\n解决此问题的一种方法是在present方法之前确保正确地移除旧页面。你可以尝试使用以下代码来移除旧页面:\n\nswift\nif let presentingViewController = presentingViewController {\n\tpresentingViewController.dismiss(animated: false, completion: nil)\n}\n\n\n然后再使用present方法显示新页面:\n\nswift\nlet viewController = YourViewController()\nviewController.modalPresentationStyle = .fullScreen\npresent(viewController, animated: true, completion: nil)\n\n\n这样做可以确保在显示新页面之前正确地移除旧页面,从而避免页面黑屏的问题。

Swift页面黑屏问题:FullScreen模式下的Present方法修复

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

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