UIImageView missing images in Launch Screen on device

后端 未结 30 1842
遇见更好的自我
遇见更好的自我 2020-11-30 16:39

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

相关标签:
30条回答
  • 2020-11-30 17:13

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

    0 讨论(0)
  • 2020-11-30 17:18

    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.

    0 讨论(0)
  • 2020-11-30 17:18

    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.

    0 讨论(0)
  • 2020-11-30 17:18

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

    0 讨论(0)
  • 2020-11-30 17:18

    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.

    0 讨论(0)
  • 2020-11-30 17:20

    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)

    0 讨论(0)
提交回复
热议问题