breakline
breakline

Reputation: 6073

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

Upvotes: 2

Views: 2799

Answers (2)

Abuzar Manzoor
Abuzar Manzoor

Reputation: 409

I was inheriting from UITabBarController instead of UIViewController from the screen I was pushing to.

Upvotes: 0

Ganesh Manickam
Ganesh Manickam

Reputation: 2139

change status of animation to false while move to next view controller this will remove the delay. Delay happening only because of animation: true. Use below code to solve your issue

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

Hope this will help you

Upvotes: 2

Related Questions