Adding png to ImageView causes black screen

My app works properly, but adding Launch Screen.storyboard, all is fine up to and including adding Image View to View; I still see the background color of View and my annotation. But when I select my photo IMG_1486 (which is file IMG_1486.png) in Image, the screen turns black. The png is fine; I can point Main.storyboard to it and it shows up correctly.

What settings can cause the black launch screen in this scenario? Thanks.
Answered by Claude31 in 665555022

there's a size limit

Yes, at least that is what I experienced for the launch screen. It may not be the pixel size only, but also the weight of the image. In a project, I did reduce from a few MB image to a few 100 kB and everything worked fine (and it did occupy the full screen, even on iPad).
In addition, that is not a serious problem for a launch screen which appears only a very short time.

Vary large images are no problem in "main storyboard" of course.

What settings can cause the black launch screen in this scenario?

iOS cannot show some types of images. Have you checked if The png is fine for iOS?
(Sorry, but I do not understand what you mean by I can point Main.storyboard.)
My Main.storyboard has a png background that works. When I change it to instead use the desired Launch Screen.png it also works, proving that the Launch Screen.png is good to use.

My Main.storyboard has a png background that works. When I change it to instead use the desired Launch Screen.png it also works, proving that the Launch Screen.png is good to use.

Can you clarify how many images do you use? a png background in Main.storyboard, Launch Screen.png and IMG_1486.png?
Without precise description of what you have done, readers cannot find what's wrong.
Two, one for Launch, one for Main. When I attach the intended Launch image to the Main storyboard view it shows correctly, but it shows black when I attach it to the Launch storyboard view. Therefore there's nothing wrong with the actual launch png. When the Launch view has no image attached, I see the view's background color and my desired annotations. So, what settings can cause a png to show black?

When I attach the intended Launch image to the Main storyboard view it shows correctly, 
but it shows black when I attach it to the Launch storyboard view. 

Sorry, but can you be more specific and precise? Storyboard does not have a property view which you can attach image.

So, what settings can cause a png to show black?

To find what, you should better describe what you have done.
In 'Launch Screen.storyboard' I select "View Controller" then "View". Then I go to "Library" and add "Image View". At this point the launch screen background color and my annotations are visible. Next in 'Image View" "Image" I select the png from the dropdown. The launch screen is now all black. Sorry, I thought this part was obvious.

I thought this part was obvious.

When everything is working as expected, it is reasonable to omit something obvious. But in this case, you need to find what's wrong.

I tested with a brand-new project of iOS/App (Storyboard/Swift) with Xcode 12.4.
  • Selected 'LaunchScreen.storyboard' (no whitespace between Launch and Screen in my case) in the navigation area

  • Used + icon and dragged Image View into the View of the only ViewController of the 'LaunchScreen.storyboard' 

(The image view is placed below the Safe Area of the View in view tree.)
  • Expanded the image view by dragging the four edges to cover whole screen.

  • Added an image to use as background into the project by dragging.

(Chose Copy items if needed and some others.)
  • Within the Attribute Inspector of the image view, chose the image

(All other attributes kept as default.)
  • The image I have chosen shows filling the view controller of Xcode or the simulator screen when run.

(Without constraints, the image may not be placed in the center of the screen.)

Can you follow this steps using the background image you want to use?
Or do you think of anything you need to mention reading the steps?

This is getting interesting.

Following your steps (thank you!), I get a solid black launch screen for a moment, then Main.storyboard turns the screen solid white as expected.

Then, just for fun, in Main.storyboard I added Image View and selected the same png selected above: The png shows up properly!

Then I went back to LaunchScreen.storyboard and deleted the Image View, and my previously added label now shows up.

So the single step that turns the launch screen black (for me) is selecting the png in the Image dropdown of Image View. If I clear the field I see the View background color and my label.

But wait! For more fun, I tried a different random png (132 x 125) and the launch screen is correct, not all black.

So my full-screen (2200 x 3300) png works fine in Main.storyboard, but not in LaunchScreen.storyboard.

So I conclude that there's a size limit (or some similar issue) to launch screen images. Is there? I definitely want my launch screen photo to cover the entire screen of every iPhone, but I suppose I can make it with fewer pixels and then have it stretched.

In case you're wondering, the launch screen is a normal photo, and the main screen is a darkened version of it so white text is legible.

I appreciate your help!

So I conclude that there's a size limit (or some similar issue) to launch screen images. Is there?

Very likely. I could have reproduced the black screen issue with my 3024x4032 jpg.

I do not know if this is a known issue or documented somewhere, but, in fact, I use a full screen image of size 1242x2688 jpg in my recent project and it shows fine.

Thanks for finding this and sharing your experience.
Accepted Answer

there's a size limit

Yes, at least that is what I experienced for the launch screen. It may not be the pixel size only, but also the weight of the image. In a project, I did reduce from a few MB image to a few 100 kB and everything worked fine (and it did occupy the full screen, even on iPad).
In addition, that is not a serious problem for a launch screen which appears only a very short time.

Vary large images are no problem in "main storyboard" of course.
Following up, I made it work by taking a screen shot of the failing png. That simple. The new one has just over half of the "Dimensions" and is about one-third the original size (4.9MB instead of 13.2MB). It looks the same to me.

Thanks for all your help!
So that could well be a size (MB) problem.

Thaks for feedback, din't forget to close the thread.
Adding png to ImageView causes black screen
 
 
Q