UIImageView missing images in Launch Screen on device

房东的猫 提交于 2019-11-27 05:51:13
Aral Balkan

Turn if 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

NikLanf

"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

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

Hope this help !

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.
andrewbuilder

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

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

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.

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;

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.

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.

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

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

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

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)

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.

I think launchscreen only support image in Assets.xcassets.

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.

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.

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

Restarting Xcode did it for me.

What did not do it:

  • Clean build folder
  • Restart device or simulator (image wasn't visible on either)

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

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

In my case I it was the image name.
I added an image named Default-568h@2x.png 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.

This is too important Must be empty! Launch Screen File

Simple solution is to use JPG instead of PNG.

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.

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

It worked for me.

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.

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

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!

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.

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..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!