Search code examples
iosxibios8.1launch-screen

LaunchScreen.xib sometimes shows as black


I'm using an xib for my launch screen in iOS8 and SOMETIMES instead of showing the correct launch screen (which is 3 UILabels over a UIImageView) it shows as BLACK. But not every time. This I can reproduce both on a simulator and a device.

If I remove or hide the underlying ImageView it seems work without this issue.

The image in the ImageView is a .png image 242kb.

Any thoughts? Of course I could just use an image instead of a xib if I have to, but wondering if this is a known issue or how to fix.


Solution

  • The launch screen is generated when the app is installed in the iOS Simulator. We could wait for that process to finish before launching the app, but we instead let that generation happen in the background. If the image hasn't finished generating by the time it is requested by the app launch, only blackness is seen.

    This is a known (and accepted) race condition in the iOS Simulator. Blocking until the image finished rendering would add a small amount of delay to the launch sequence every time you clicked Build&Run. If you want to debug the launch screen, you can quit the app (remove it from app switcher) and relaunch it manually (not via build & run).

    This may decision may change in the future, but for now it shaves off a little bit of time between when you click "Build & Run" and when the app finishes launching.