Technical Q&A QA1709

Why does my app launch to a black screen on iOS 4?

Q:  Why does my app launch to a black screen on iOS 4?

A: Why does my app launch to a black screen on iOS 4?

While setting your main window to be visible at launch has always been a requirement, earlier versions of iOS didn't strictly enforce this. In iOS 4, not setting your main window to be visible at launch will result in your application launching to a black screen and your main window not becoming the first responder.

If your app is launching to a black screen, make sure you have one of the following methods implemented.

In Xcode

In the App Delegate's -applicationDidFinishLaunching: or -application:didFinishLaunchingWithOptions: method, make sure you call [window makeKeyAndVisible].

This will set the main window as visible on launch and will make it the first responder.

In Interface Builder

If you have no need to use -applicationDidFinishLaunching: or -application:didFinishLaunchingWithOptions:, or you would rather set the window to be visible and the first responder in Interface Builder:

  1. Open MainWindow.xib in Interface Builder.

  2. Select the Window object in the Document window (see Figure 1).

  3. On the Attributes tab of the Inspector palette, set the "Visible at Launch" checkbox to checked (see Figure 2).

  4. Save MainWindow.xib.

Setting your main window to "Visible at Launch" in Interface Builder is the same as calling makeKeyAndVisible on the window in Xcode. There is no need to have it set in both places. Choose the one that makes the most sense for your needs.

Figure 1  The Document window with the Window object selected.
Figure 2  The Inspector palette with "Visible at Launch" checked.


Document Revision History


DateNotes
2010-07-28

New document that shows how to resolve a black screen on launch by making your main window the first responder and visible on launch.