首页 > 解决方案 > Swift 4 present view controller black screen

问题描述

I'm presenting another view controller like this:

func goToScreen(id : String) {
    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let newViewController = storyBoard.instantiateViewController(withIdentifier: id)
    self.present(newViewController, animated: true, completion: nil)
}

The problem is, there is a cc. 1 second delay between the appearance of the new viewcontroller, and in the meantime the app shows an all black screen. Why is that? It looks really ugly

标签: iosswiftxcodeuiviewcontroller

解决方案


在移动到下一个视图控制器时将动画状态更改为 false,这将消除延迟。延迟仅因动画而发生:是的。使用以下代码解决您的问题

self.present(newViewController, animated: false, completion: nil)

希望对你有帮助


推荐阅读