UIImageView missing images in Launch Screen on device
Asked Answered
U

35

309

I have an app that supports iOS8 and later, built in Xcode 7 and I am using a XIB for a Launch Screen (I do not have launch images). The view contains a single UILabel with the app version, and 2 UIImageViews with images that are both present in Images.xcassets: A logo and a splash image.

The UILabel and the logo image appear correctly when I launch the application, but the splash image does not if I run the app on an iPad Air 2 with iOS9. I have tested on an Air and a Mini running iOS8, and iOS9 simulators for iPad 2, iPad Air, and iPad Air 2 and the image appears correctly in all of those.

I ran some basic troubleshooting to see if I could figure out what is going on but I haven't been able to solve it and the only difference I can see between the image that's working and the one that's failing is when I added it to the assets...

Here's a rundown of what I know:

  • The UIImageView for the splash image is in the correct place, at the correct size. I can tell this because I set its background color to green just to make sure. The view is there, but the image does not appear. So I'm assuming that the view is not to blame.

  • Setting the UIImageView for the splash image to also use the logo image makes the logo image appear in the correct place for the view. This also leads me to assume that the view is not to blame.

  • The UIImage that I am using in the splash image view is used elsewhere in the app and appears fine in those other views (the logo image is also used elsewhere in the app and appears fine). So I'm assuming that the image is valid and having it appear in other views is not a problem.

  • I've confirmed that the settings of the UIImages for the logo and splash in the xcassets file are the same. They are set to Universal, Any width and height, multiple scale factors, rendered as default. There is one difference - the logo has 1x, 2x and 3x scales while the splash image only has 1x and 2x, but I have also tried using UIImages with only 1x, and 1x and 2x values in the UIView and they work (if they were added to the project some time ago).

  • Adding another image of a different size or format (PNG and JPG) to my xcassets and using that UIImage in the UIImageView for the splash image also fails to display.

  • Adding another UIImageView to the XIB file and allocating it a UIImage that was already in the xcassets works, the image appears in the loading screen.

  • Copying and renaming the image files used for the logo and adding them to the project then using that UIImage in the splash view also fails to display.

  • I have tried cleaning the project, restarting the development machine, and deleting the app from the Air 2 and reinstalling it just in case that was a problem.

These last three steps lead me to believe that there's some issue with images added after a certain point in the project file's lifetime. While I updated to Xcode 7 yesterday, the splash image was originally added in Xcode 6, but the logo image (also added in Xcode 6) was added some months before.

I've looked over the json files for the logo image and splash image and they appear to have the same format. I've also trawled through the pbxproj file looking for differences and I can't see any.

So I was wondering if anyone had any idea why the launch screen might not display these new images I'm adding on the Air 2 specifically? Other questions I've been reading through relating to images not appearing all seem to relate either to Launch Images, or to images in XIB files that have associated classes, neither of which seems relevant here.

Unlock answered 15/9, 2015 at 6:29 Comment(5)
Been meaning to reply on this - I came back and read over the answers provided, then returned to Xcode and re-adedd the UIImageView and image in order to try them out. This time, it worked without any changes. I have no clue why - same version of Xcode, I restarted, rebuilt, cleaned and removed the app before, same iOS, same Mac OS, it just worked. So unfortunately I haven't been able to verify if any of the solutions would have helped.Unlock
For me NONE of the provided answers solved the problem. Simulator, iPhone 5, iPhone 5 SE, iPad 4 are all displaying the UIImageView within my LaunchScreen.xib correctly, iPad Air 2 won't show it. Rebooted all devices, re-installed on all devices. Behaviour remains.Chuck
Hey you should accept the 130+ voted answer.Mikaelamikal
I agree with Khanh, it is working for most!!Elbert
@MFW, ACCEPT THE ANSWER FFS! IM REPORTING U TO THE COPS.Chicanery
M
485

Turn it off and then on again.

Seriously, restart the device — that’s what fixed it for me.

Here’s what didn’t work:

  • Cleaning DerivedData.
  • Cleaning the project.
  • Uninstalling the app from the device.
  • Restarting Xcode.
  • Restarting the computer.

Older observations:

Just like the others, it:

  • Works fine in the Simulator
  • Used to work on the devices (iPhone 5S, iPad Air)
  • No code changes (verified via git reset --hard HEAD), yet stopped working.

What I remember triggering the first build where it stopped working was unplugging the iPhone while it was runnning. (Not sure if it’s related.)

However, the git reset not fixing it (combined with all the clean steps not working) tells me it this must be getting cached somewhere else. Quite possibly in one of the .gitignored files? (I’m using Git ignore file for Xcode projects)

One workaround that worked for one UIImageView (in the UIView that has three) but not for the others was putting the image into an .xcassets file. Reverting to the plain image file did not undo the fix. (Really feels like a caching error.)

UPDATE: See top — restarting the device is what fixed it. I get the feeling the wrong bitmap data is being cached on the device itself.

Radar: http://openradar.appspot.com/23534818

Murderous answered 13/11, 2015 at 17:4 Comment(20)
Simply restarting the simulator did it for me. Crazy!Consume
Do you think App Store users are going to experience the same problem?Sweepback
Wow, so simple, I was going nuts. It really isn't anything but memory pressure I guess. Apple has put extra caution on LanuchScreens being displayed in a timely fashion, therefore it will simple avoid stretching or even displaying images if app thinks it'll take too long. Thanks anyway.Petropavlovsk
I've tried many ways, but every times i run the app on my cellphone, this error happens. how to fix this error thoroughly?Fireweed
@AdamWaite wondering if your users experienced this once the application was released in the App Store.Margarettemargarida
@danielstorm never found out to be honestSweepback
Simply restarting on Device ..... Uau it.s very crazy!... I believe a bug with xCode !Socinus
This didn't work for me, but the answer from NikLanf did. Unchecking 'Clears Graphics Context' on the UIImageView fixed it.Valetudinary
2016. iOS 10. Bug still there.Haven
Thanks for sharing, sadly I already lost an hour of my life. My guess is that the LaunchScreen storyboard is being kept "in cache", so it doesn't read any change in the image files until you restart.Linguiform
@Aral Balkan Jesus, man! Restarting the device did the trick iOS 10.2.1 Xcode 8.2.1. Big thanks!Experiential
Restart on itself was not enough (when launching the app again from the iPad), but doing a (re)build and launch from Xcode did the trick!Birgitbirgitta
Worked for me! Too weird! I'm sure Apple engineers are reading this saying, "You know, we really ought to fix that one of these days."Wheedle
Same with me. Restarted the device and then running the app again from XCode. Works. XCode 9 still having this stupid bug. But lets create a notch on iphoneX. ffs apple.Chicanery
Thx! Worked for me also, but I have to do few additional steps: 1. uninstall app 2. restart device 3. install appPurvey
Didn't worked for me on my iPad Air 2. NikLanf's solution worked :)Roble
I was testing on my device (iPhone X 256GB) and wasted 1h trying different images from Asset catalog, all except the one I wanted was working. That led me to think the problem was the file format, regenerated the file several times. Nothing worked... until I found this. Simply rebooting device fixed it all. THANK YOU Aral and STACKOVERFLOW, I can't imagine a developer life before you.Hanshansard
Restarting is still required on iOS 13. I also needed to delete the app from the device and clean the project at the same time, before launching the app again. Otherwise the wrong launch screen gets cached again, and another restart is required.Poynter
4.5 years down the road in the year 2020 with Xcode 11 now and we still need to restart the simulator device.. wow. Just imagine the hours saved by people around the world if someone at Apple actually took some time to fix this.Outlast
Just rebooting the simulator is enough...Hardhack
H
155

"The solution for me was simply to make sure that the "Clears Graphics Context" box is unchecked for the UIImageView in the storyboard. Just changing this fixed it for me." No other solutions worked for me. Got it from apple developer forum

enter image description here

Hashim answered 18/2, 2016 at 12:33 Comment(10)
Damn, I never would have thought to try this. Fixes Simulator and Device with Xcode 7.3.1 (7D1014) and iOS 9.3.2 Developer Beta 3.Buenrostro
I can confirm this also worked for me. Xcode 7.3 and iOS 9.3.2.Aerobic
Even with mine already checked -- unchecking and rechecking did the trick!Cantor
When having image in .xcassets this doesn't work but after adding image directly to project this started working. Thanks!Vernacularize
Damm! Weird. +1 for your answer! Thanks a lot. Saved my time.Polypus
Nice +1 for your answer , works in Xcode 8 and iOS 10 as wellAllottee
This only worked for me when The image is directly added to the project not trough assets which sadly is only in 1 sizeThunderstorm
Thanks! Fixed this issue for me in XCode 8.3, launchscreen storyboard, using a PDF/vector image from assets catalogConsonantal
This is the correct answer. Proved on iOS 11, on device.Mullock
Why in the hell do they automatically check this for you? Thank you so much, you saved me a lot of time.Ides
O
101

I had exactly the same issue on an iPhone 6.

The very strange fact is that I was able to use another image from my images.xcassets which had the same size, compression, color space ...

I'm not able to find why it doesn't work but I found a solution : Simply put your file outside your images.xcassets and use its full name (with extension) in Interface Builder

splashScreen in storyboard sample

Hope this help !

Oby answered 24/9, 2015 at 1:0 Comment(10)
That was the first thing I tried, but it doesn't work for me.Lanthanum
This worked for me; thanks. I wish I knew why it was only working for some images in xcassets files though...Jankey
This works for me to begin with, but now the image or label properties are not updated at all. Even after a clean product action. Filed a bug here: bugreport.apple.comAlysiaalyson
Restarting the iPhone 6s after deletion of the app did the job. Prior to that NikLanf solution below "clears Graphics Context" was also check.Stark
This works. The reason is I think due to .xcasset is yet not loaded when the launchscreen is shown. If you think about it, that is what launchscreen is for - a waiting time for ios to load app content, which includes xcasset. My guess is putting it outside works since everything in root folder of app will be loaded first.Chicanery
Update for Xcode 8.3.2: the bug still exists, but this fix works :)Lemieux
So dumb... this worked for me on XCode 9 beta when the splash image was different from the app icon -_-Buchalter
Thanks a lot! Top 2 answers did not work in my case. Using XCode 9.2 with iOS 11.2.5Showmanship
This worked for me with UIImageViews that had outlets - Xcode 9.0.1 iOS 11.0.1. Still hard to believe this works - so simple. Going to make the tree hard to navigate - over 100 pngs for flags. Oh, well.Haland
Xcode 9.4 and it still isn't fixed, your solution worked like a charm though.Shainashaine
C
33

The following sequence of operations fixed the issue for me on Xcode 7.3.1 and iOS 9.3.4:

  1. Clean Your Build (⌘+⇧+K)
  2. Close Xcode
  3. Hard Reset iOS Device (Power + Home Button reboot)
  4. Relaunch Xcode - let indexing finish and build on device once it is ready.
Cowherd answered 7/8, 2016 at 8:4 Comment(6)
Saved my day! Thanks!Glassblowing
Worked. I did not do steps 2 and 4, Perhaps only a Hard Reset of the iOS device is needed, can anyone confirm this?Athalee
@TimothyL.J.Stewart Steps 2 and 4 were just more precautionary steps that I had taken because the issue was quite an annoyance for me - so it was just to be sure. I think you're right in saying they might be unnecessary since they do not really (typically) affect the build.Cowherd
Xcode 8 Swift 3.0 Powering off or Hard Resetting is the only thing that works every time, and must be done every time a new asset is added. Deleting DerivedData does not. However, the image works properly in the simulator. This has wasted so much of my time, thank you @MayankKumar for the solution.Athalee
Worked like a charmOutmaneuver
This worked for me on my device and simulator. I didn't even need to restart Xcode. iOS 11.3Gnathous
M
29

Many other answers suggest rebooting devices and / or rebuilding and / or reinstalling is the solution.

While these answers work for some of us, the reason these work is because the app is forced to "retake" or "rebuild" cached snapshots.

Cached snapshots are used by apps to present images before supporting data is loaded into memory, including the asset catalogue that contains storyboard images.

This SO answer by @jaga provides the solution, but not the reason, as to why UIImageViews are missing in the Launch Screen on device (but not in the simulator).

Background

Recently I attempted to use a custom font in my "Launch Screen.storyboard" file.

The reason I could not became clear after reading this SO answer by @TimCamber, which prompted me to do a little more research and testing.

The reason that a custom font is not included in my Launch Screen Storyboard file is the same reason an image within an asset catalogue is not included...

The app prepares portrait & landscape snapshots of the app's Launch Screen from your Launch Screen Storyboard file and (currently) saves it in your app bundle here:

  • /Library/Caches/Snapshots/<<app_bundle>>/ and
  • /Library/Caches/Snapshots/<<app_bundle>>/downscaled/.

This process is complete before any supporting files are loaded, including any custom fonts and the asset catalogue.

Solution

As mentioned above by following @jaga's solution, literally all that is required is to:

  1. (old school) add an image file (.PNG) to your app's bundle (as you can see from the screenshot below I added the image file under the Supporting Files subdirectory in an Images subdirectory), and

screenshot of relevant directories in Project Navigator in Xcode

  1. reference that image in your UIImageView object in the Launch Screen Storyboard file...

screenshot of Image View section for UIImageView under Attributes Inspector in Xcode

Misjoinder answered 19/4, 2016 at 2:58 Comment(5)
Thank I've been wrestling with this for a little while. That works for me.Byrn
worked for me directly. this should be the correct answerMercer
On Launch IOS was not able to compile assets so placing your image to bundle works. Thanks.Morpheme
Best answer so far. I will add this: the image has to be in the app-bundle's root directory. Otherwise you have to give the full path "Media/launch_v1_200_mod.png" if you store images in a sub dir.Preservative
I did the same. My app is already live but the issue is sometimes it is showing the image and sometimes it shows square with white color in the middle of the screenXenocrates
C
21

I was seeing the same problem. Rebooting the device (iPhone 6) and rebuilding the app to the device is the only thing that fixed it. I tried many other tips and suggestions but nothing else worked. Only reboot + rebuild helped.

Cranberry answered 16/11, 2015 at 22:52 Comment(1)
How will it look like if the user will update the app from the AppStore? Will he need to reboot his device ?Vase
E
19

My solution @iOS 11.x:

  • Use .jpg image instead of .png. I think image file size matters;
  • (Optionally) Put image file in project directory rather than .xcassets;
Eire answered 8/1, 2018 at 2:58 Comment(5)
Putting the image file outside of .xcassets helpedAntisepticize
@Antisepticize I really think it’s file size that only matters. I have a launch screen with two images: a large one (400+KB .png) and a logo (10+KB .png, inside .xcassets). The logo always show up normally, but the large one doesn’t.Eire
You are right .. After my comment the issue appeared again after adding another image. Thanks for your helpAntisepticize
Then followed your instructions by using jpg image and workedAntisepticize
What if you need transparency?Folium
I
16

I had the same for app installed from TestFlight. Delete app -> then restart iPhone -> then reinstall app works for me. Just reinstall app or just restarting device didn't help.

Intrados answered 28/1, 2016 at 16:59 Comment(3)
This is the only thing that worked for me - wish I had seen this 90 minutes ago !Socha
wish I had seen this 4 hours agoTorrez
Worked for me as well, but the problem is weird :|Adams
S
9

What worked for me was to select Reset Content and Settings... from the Simulator menu

Reset content and Settings menu

Satang answered 8/1, 2017 at 4:58 Comment(1)
Three years later and this is what fixed it for me. It is now Device > Erase All Content and Settings...Jarmon
M
8

I was having the same problem, but restarting the device didn't help. What worked for me was deleting the UIImageView from my launch storyboard and adding a new one.

Monagan answered 23/12, 2015 at 0:42 Comment(0)
S
8

Have you tried turning the device off and on again? Do it.

Silk answered 28/2, 2016 at 19:2 Comment(0)
E
6

Bring images out of Image.xcassets and add them again to project. It worked for me.

Equiprobable answered 29/3, 2016 at 4:0 Comment(1)
That works only because you are forcing the app to recreate the Launch Screen snapshots, but it is not a solution to or reason for the problem.Misjoinder
C
6

Remove app from mobile and then restart mobile and install app again. now the issues will be solved

Caen answered 25/4, 2019 at 6:42 Comment(0)
E
5

I also had this exact problem in Xcode 7 with iPad and iPhone devices. Although it makes no sense, I was able to get around it most of the time by setting not only the Image but also the Highlighted image in the image view to the same image in my images.xcassets.

Eccentricity answered 25/9, 2015 at 13:6 Comment(1)
Seems to be helped for me tooLepidolite
D
5

I use the iPhone 5s device, also meet this problem.

I fix it by :

  • Remove Drive Data

  • Clean the project

  • Restart Xcode

  • Remove the project from my device

  • Restart the 5s.

I think it's something wrong of Xcode to use memory, system may be allocate a little memory for Xcode cause Xcode drawing the lunch image failed (On my computer , Xcode have runned for several weeks without close)

Discobolus answered 2/12, 2016 at 3:52 Comment(1)
I do not know, but it worked.. like good. Thanksw man for sharing.Obelisk
W
5

it's worked for me.

First in xcode clean de project.

If you use the simulator, delete app and relaunch.

If you use a device, delete app and restart the device.

Wretch answered 18/9, 2017 at 3:4 Comment(0)
V
4

I think launchscreen only support image in Assets.xcassets.

Velodrome answered 28/2, 2017 at 8:13 Comment(1)
I tried all the answers above and none of them worked for me. But this answer solved the issue.Disclosure
O
3

Restarting Xcode did it for me.

What did not do it:

  • Clean build folder
  • Restart device or simulator (image wasn't visible on either)
Originality answered 21/3, 2016 at 23:33 Comment(0)
S
3

Select the ImageView and then remove the image extension (.png or .jpg) in the attributes inspector tab > Image view > Image > Image Name.

On launchscreen.storyboard the image will not appear but it will be there in device. This worked for me.

Shagreen answered 9/2, 2017 at 12:6 Comment(1)
This was my problem too. Strangely it randomly worked on some devices. Xamarin-Project with Xcode 9.4 for XIB/Storyboard editing...Roble
F
2

It seemed a bug of iOS. Like sometimes the system animation disappeared.

Now I just reboot the iPhone and it is worked for me.

Fisticuffs answered 12/5, 2016 at 4:12 Comment(0)
L
2

In my case I it was the image name.
I added an image named [email protected] to LaunchScreen.xib - one of my old launch screens just for testing purposes. I was building on the iPhone X Simulator, the image didn't show up.

Changing the name to something neutral (MyImage.png) solved the issue.

It seems that the @2x was part of the problem as well as the -568h. Which makes some sense on a -812h@3x device.

Liliuokalani answered 13/11, 2017 at 15:58 Comment(0)
S
1

I have the same issue with imageView a launch screen storyboard. I removed reference of picture from project, I renamed my image and added it again to project. All works perfectly.

Subclinical answered 21/4, 2016 at 13:8 Comment(0)
M
1

Also can 1. delete project image 2. change image name 3. add file image to project

It worked for me.

Mechanistic answered 3/8, 2016 at 13:46 Comment(0)
P
1

This is too important Must be empty! Launch Screen File

enter image description here

Professor answered 7/9, 2016 at 11:35 Comment(1)
He's using the XIB storyboard for launching, this answer will not work.Vietnam
T
1

Next helped to me:

  • change "Launch Screen File" to another xib
  • run the app
  • change xib back

Also very important: check that your is xib not opened in another tab, that can cause it as well!

Train answered 27/10, 2016 at 13:30 Comment(0)
S
1

I had this problem in iOS 10 on an iPhone 6 and also in the Simulator. My image was in a folder and that seemed to be the issue. I removed the image from the folder in Xcode and put it in the project's base directory which solved the problem.

Selfgratification answered 3/4, 2017 at 20:43 Comment(0)
A
1

I experience the same. I change image resolution from 300 pixels/inch, change it to 72. It works for me.

Ackler answered 27/4, 2017 at 22:5 Comment(0)
E
1

I found a simple but radical solution that worked for me :

1 - Delete the file : LaunchScreen.storyboard and move it to trash.

2 - Product -> Clean

3 - Create a new launch screen file named : LaunchScreen.storyboard and put your images in it

4 - Save and build

That worked for me after trying complex methods for hours... It seems that my LaunchScreen.storyboard was write-locked and couldn't be saved or a weird caching process was blocking it.

Exhalation answered 8/8, 2017 at 8:44 Comment(0)
L
1

Simple solution is to use JPG instead of PNG.

Lawtun answered 5/6, 2018 at 21:24 Comment(1)
JPEG doesn't support transparency.Folium
C
1

Image name is the problem. Rename the image name used inside the Launch screen storyboard. Make sure not to use any character other than alphanumeric ( don't use "_-&@") Worked for me like a charm..

Cough answered 6/6, 2018 at 17:36 Comment(0)
P
1

SOLVED!

The only thing that worked for me was deleting the ViewController from LaunchScreen.storyboard and create a new ViewController set to

Is Initial View Controller

Simple as that :)

Phloem answered 12/11, 2018 at 22:1 Comment(0)
C
0

In my case, i just go to app TARGETS -> General -> App Icons And Launch Images -> Launch Images Source Then select source where i put the images Hope this will help you

Constipate answered 6/7, 2016 at 15:27 Comment(0)
C
0

For me, the problem was that the size of my Launchscreen was off by 1 pixel (2209x1242 instead of 2208x1242). Correcting it, then rebooting the device and rebuilding the app helped.

Circumlocution answered 11/7, 2016 at 8:10 Comment(0)
J
0

"myProject" is with many images initiated from Images.xcassets. But I Ran into missing images after deleting and restoring “Assets.xcasset” from project.

  1. Deleting Images.xcassets accidentally, but
  2. Adding Images.xcassets back to "myProject"

I ran into this missing images problem, and tried following methods:

  1. Recycle power of the device, but it doesn’t work.
  2. Using Xcode to "build" project after "cleaning", and it doesn’t work either.

Solution to fix my problem:

  1. Added every and each image inside Images.xcassets back to "myProject" via Xcode in “Target Membership” at “Show in File Inspector” and it is back to normal.
Jest answered 22/9, 2017 at 18:21 Comment(0)
S
0

Select your image file from left menu, select "show the file inspector" from right Utilities menu. Under target membership make sure your target is selected. I added the image with selecting the target but I don't know why it was unselected. I tried all solutions, restarting, deleting etc. no one works. Just this worked. Hope it helps someone else.

Scandinavia answered 4/10, 2017 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.