iOS 8: Launch Screen StoryBoard appears black [single XIB file works fine]

24,532

Solution 1

Read through the tutorial and tested it, and it doesn't say two things:

1: You'll need to add a UIViewController to your .storyboard file, and then select it as the Initial Controller.

2: If you wish to change more than just the launch screen, you'll have to go to the project settings and set the "Main Interface" to your corresponding .storyboard.

Once that is done, all you need to do is edit the UIButton/Label/etc connections to your ViewController classes.

EDIT:

For clarification, you can set a UIView as the initial controller by selecting it in it's respective storyboard file, then opening the Attributes Inspector. The option for 'Is Initial Controller" is towards the middle.

Solution 2

For people using UIImageView in the launch screen

Make sure that you are using the image name without the extension in the attributes inspector.

So for example, if your image file is named launcher.png, only use launcher as image name.

This will show the image as invalid (?) in the editor but will show correctly when run on device.

(Don't ask me why it works this way. Ask Apple.)

enter image description here

Solution 3

None of the answers have all the steps required, hence this exhaustive solution.

Storyboard

Start by creating the LaunchScreen.storyboard. Xcode > File > New > File... > Storyboard > LaunchScreen.storyboard and add it to all appropriate targets.
In this storyboard, create a single view controller of type UIViewController. Do all the magic your launch screen requires, then follow these steps:

  1. LaunchScreen.storyboard > Show the File inspector > Use as Launch Screen

  2. LaunchScreen.storyboard > View Controller > Show the Attributes inspector > Is Initial View Controller

  3. Project > General > Deployment Info > Main Interface > LaunchScreen
    Repeat for [iPhone] and [iPad]

  4. Project > General > App Icons and Launch Images > Launch Screen File > LaunchScreen

  5. If setup properly, your Info.plist should have LaunchScreen .storyboard, without the .storyboard under the UILaunchStoryboardName & UIMainStoryboardFile properties:

    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>LaunchScreen</string>
    

Notes:

  1. This is not incompatible with having legacy images for older devices using Launch Screen File > Assets.
  2. Pay special attention to LaunchScreen.storyboard and Main.storyboard. One is used for launch, the other for your app entry point. They both need to have Is Initial View Controller set.

Solution 4

In the storyboard, which you are using for launching, please make sure that you had selected the option of Is initial view controller for the very single view controller present in it.

Solution 5

I Belive I may have had a similar issue that required something a littel different to the above answers.

I created a new launch screen in a .storyboard file, then after it not appearing I resulted to a new .xib file which still did not appear when the app was launched.

I figured out that some of the images I had on my launch screen had an Outlet Collection to an old .swift file. After removing this from the LaunchScree.xib's the launch screen worked fine.

the broken outlet

Notice the litte warning sign in the outlet reference -> The warning

Share:
24,532

Related videos on Youtube

Darvish Kamalia
Author by

Darvish Kamalia

Updated on January 13, 2021

Comments

  • Darvish Kamalia
    Darvish Kamalia over 3 years

    So I tried creating a launch storyboard for my iOS 8 app using this tutorial

    However, I only get a black screen when I launch my app. A single launch screen.xib file works perfectly, however, when I try to use a storyboard, it doesn't work.

    I tried a storyboard with just a single view controller, but it still gives me a black screen, hence I believe the issue is with storyboard files in my setup. Any ideas?

    [XCode version 6.4]

    EDIT: So I just want to clarify that it is the launch screen that appears black. The main storyboard itself appears correctly when the app has finished loading

    • Ersin Sezgin
      Ersin Sezgin almost 9 years
      You can only use a launchscreen.xib kind of file instead of splash screen. After that you need a storyboard file which needs to have a initial view controller.
    • Darvish Kamalia
      Darvish Kamalia almost 9 years
      I'm pretty sure iOS 8 added support for storyboard files as launch screens. At least, that is what the tutorial says.
    • Ersin Sezgin
      Ersin Sezgin almost 9 years
      Okay, now I checked it from the documentation and you are correct. My bad :)
    • primehalo
      primehalo about 8 years
      My launchscreen.storyboard was also showing only black. I found that it was actually the image view that was showing black, labels would show up fine (I just didn't realize it at first because I had my image covering the entire view). For some reason the issue was due to my image file's name. After renaming my image from launchscreen.png to anything else, like launch-screen.png, it started working. I have no idea why.
  • Darvish Kamalia
    Darvish Kamalia almost 9 years
    Yep. Setting it as the initial view controller fixed it. Follow up question though: I also have my actual initial controller (in Main.storyboard) set up as the initial controller. Shouldn't this create a conflict since there are now two initial controllers (one in LaunchScreen.storyboard and one in Main.storyboard)? EDIT: nvm. Apple documentation states that the initial view controller is the controller displayed when that particular storyboard becomes the app's main interface. Consequently, each storyboard should have it's own initial view controller.
  • CraftMcMatt
    CraftMcMatt almost 9 years
    Actually, no. The "Initial Controller" is the Initial controller of the storyboard, not the entire application.
  • primehalo
    primehalo about 8 years
    When I do step #3, my launch screen is still black on launch and then after the app is loaded my launchscreen storyboard is presented instead of my main storyboard... so I don't think that step is right.
  • SwiftArchitect
    SwiftArchitect about 8 years
    Make certain that you do not have discrepancies between Main.storyboard and LaunchScreen.storyboard. These are 2 distinct storyboards, I clarified the answer.
  • JeffB6688
    JeffB6688 about 8 years
    I agree with @primehalo. Step #3 doesn't seem right. Same thing happens to me. In fact, it doesn't make sense that the main interface would be the launch screen. What do you mean by ensuring that there isn't discrepancies between Main.storyboard and LaunchScreen.storyboard? Do you have an example of a discrepancy?
  • SwiftArchitect
    SwiftArchitect about 8 years
    Rephrasing: it is easy to pick the wrong .storyboard. As noted in 2, you want to set Is Initial View Controller in LaunchScreen.storyboard
  • zero3nna
    zero3nna over 7 years
    works like a charm and describes all possible issues.
  • Yitzchak
    Yitzchak almost 7 years
    Amazing!! the wierd thing that it worked with the extension until I added support for older iOS versions (min 8 instead of 9), that made my storyboard editor very buggy, and removing the extension did the trick. thx!
  • Ramakrishna
    Ramakrishna almost 7 years
    I don't know why but this saves my day.. Thanks for the answer.
  • Yvo
    Yvo almost 7 years
    Your LaunchScreen is most likely a different storyboard than your MainScreen storyboard. Steps 3 and 5 are confusing, that should be MainScreen. One more tip: make sure that you don't have a . in your filename, I made the mistake of separating two target storyboards with a ., it is better to use a dash instead, e.g. Launch-Target1 and Launch-Target2.
  • Ramakrishna
    Ramakrishna over 6 years
    Hi, I'm facing the same problem. And i've added the both localizations in LaunchStoryboard.storyboard, But still having the black screen issue. Do you have any other solutions?
  • JeffB6688
    JeffB6688 over 6 years
    This answer, along with all the rest, do not work long term. It is so frustrating. Each time the screen goes black, I toggle between using the .png extension and removing it. Does anyone have a permanent solution with a clear explanation why it will work?
  • Ehtesham Hasan
    Ehtesham Hasan over 6 years
    @JeffB6688 Consider this problem as an Xcode fart. :)
  • JeffB6688
    JeffB6688 over 6 years
    @EhteshamHasan Its actually more than an Xcode fart. I now have an app in the app store that has a black launch screen. While it worked in my final test before uploading, the last build that occurs when archiving it caused it to go black again. I have to believe that I am doing something wrong and would love to find a definitive solution.
  • ChrisH
    ChrisH about 6 years
    What an utterly idiotic work around (that's a dig on Apple, not the poster of this fix, which kept me from throwing my computer at the cat in frustration). Thanks, man.
  • kennymuse
    kennymuse about 6 years
    This happen because the LaunchScreen.storyboard accept only images inside Assets.xcassets and the way to refer the images inside Assets.xcassets is the name of the resource without extension. I think that use the name without extension is a workaround that work.