简体   繁体   中英

UIImageView is black on launch screen

I sometimes face a very strange issue on launch screen. I'm using a xib file with just a UIImageView on it, however sometimes the image is just a black rectangle.

I've tried to switch between .jpg and .png files but this didn't help, I've also assigned a different image property profile to it.

This happens on devices running iOS 9.

在此输入图像描述

These are the constraints for the UIImageView . I've removed the image, as it's a logo of a client.

在此输入图像描述

在此输入图像描述

I have the same problem. I've tried:

  • move the .png file to Images.xcassets. fail.
  • create a new LaunchFile.storyboard. fail.
  • rename the .png file. work for a while, but after you perform the Build&Run action(same with Run without building action) a few times, the issues occur again. very weird.(sometime you need to reopen the Xcode to reproduce the issue)
  • test the same LaunchFile.storyboard in a new project. the LaunchFile is correctly displayed in the new project, very confused me.

Finally, i found a way which works not only for temporary(I've tested for one hour, just repeat build and run for like 100 times, watch TV meanwhile).

This issue is somehow related to the .png image. I dragged my .png file to photoshop, then go File > Save for web (Command + Option + Shift + S), make sure the transparency is unchecked, export a new .png file. replace the old file with then new one you'll find the issue is fixed.

But I'm still confused why a issued .png file can work for a while.

I have the same problem that appears from time to time on some devices. Last thing that helped was a full restart of a device.

Not sure what the original issue was really, I fixed it by manually generating legacy splash screens though.

One issue with debugging that may be helpful was that it persisted when updating the build (even when the app was deleted) until I both deleted the app and shut down the device. I guess the splash screens are getting cached and so this clears the cache. I hope this helps save some folks some time, if anyone knows why this was happening, I'd still be happy to know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM