Harry Merzin
Harry Merzin

Reputation: 416

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

Upvotes: 2

Views: 560

Answers (3)

Ahmed Lotfy
Ahmed Lotfy

Reputation: 3906

May be you use an empty UIViewController(). In my case I set a default value an empty UIViewController()

Upvotes: 0

owlswipe
owlswipe

Reputation: 19469

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 will just never launch and your screen will stay black.

Upvotes: 2

cerebro_assassin
cerebro_assassin

Reputation: 111

There might be many reasons for blank black view. But first check whether you have the window variable declared in your appDelegate as suggested by @john. If this doesnt work, check in the storyboard whether you have made your first controller as initial view controller.

You can also do this by adding rootviewController as the view controller you want in the window inside application:didFinishLaunchingWithOptions:

Upvotes: 1

Related Questions