Harry Merzin Harry Merzin - 6 months ago 24
iOS Question

iOS app launches to black view

I have been trying to run my Xcode project on my iOS simulator an iPhone but I only get a black screen. I have tried multiple solutions but none seem to work.

I have tried:


  1. Setting main interface to "Main.storyboard"

  2. Installing all views i.e.: width: any, height: any

  3. Adding print statement to
    viewDidLoad
    to state that the view did in fact load (didn't print that the view loaded)

  4. Resetting all content of the iOS simulator

  5. Running on my iPhone

  6. Setting initial view controller



None of these have solved my problem

Answer

Make sure in your AppDelegate that you are creating the variable window like so (right after the app delegate class declaration): var window: UIWindow?.

Without this line of code, your views just never launch.