UIImageView在设备上的启动屏幕中丢失图像 [英] UIImageView missing images in Launch Screen on device

查看:196
本文介绍了UIImageView在设备上的启动屏幕中丢失图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个支持iOS8及更高版本的应用程序,内置在Xcode 7中,我使用XIB作为启动屏幕(我没有启动图像)。视图包含一个带有应用程序版本的UILabel,以及两个带有图像的UIImageViews,这两个图像都存在于Images.xcassets中:一个徽标和一个启动图像。



UILabel和启动应用程序时,徽标图像会正确显示,但如果我在带有iOS9的iPad Air 2上运行该应用程序,则不会显示启动图像。我已经在Air和Mini上测试了运行iOS8,以及适用于iPad 2,iPad Air和iPad Air 2的iOS9模拟器,所有这些模型都能正确显示。



我运行了一些基本的故障排除,看看我是否能弄清楚发生了什么,但我无法解决它,我能看到的唯一区别是工作的图像和失败的图像是我将它添加到资产...



以下是我所知道的概述:




  • 启动图像的UIImageView位于正确的位置,大小正确。我可以告诉这个,因为我将它的背景颜色设置为绿色只是为了确保。视图在那里,但图像不会出现。所以我假设视图不应该受到责备。


  • 为启动图像设置UIImageView也使用徽标图像使徽标图像显示在视图的正确位置。这也让我认为视图不应该受到责备。


  • 我在启动图像视图中使用的UIImage在应用程序的其他地方使用在其他视图中显示正常(徽标图像也在应用程序的其他位置使用,看起来很好)。所以我假设图像有效并且在其他视图中显示它不是问题。


  • 我已经确认了UIImages的设置对于xcassets文件中的徽标和启动是相同的。它们设置为通用,任意宽度和高度,多个比例因子,呈现为默认值。有一个区别 - 徽标有1x,2x和3x刻度,而启动图像只有1x和2x,但我也试过在UIView中只使用1x,1x和2x值的UIImages它们可以工作(如果它们是在不久前添加到项目中。)


  • 将另一个不同大小或格式的图像(PNG和JPG)添加到我的xcassets并在其中使用该UIImage用于初始图像的UIImageView也无法显示。


  • 将另一个UIImageView添加到XIB文件并为其分配已在xcassets中工作的UIImage,图像出现在加载屏幕中。


  • 复制和重命名用于徽标的图像文件并将其添加到项目中,然后在启动视图中使用该UIImage也会失败要显示。


  • 我已经尝试清理项目,重新启动开发机器,并从Air 2中删除应用程序并重新安装它以防万一问题。




这最后三个步骤让我相信在项目文件的生命周期中的某个点之后添加图像存在一些问题。虽然我昨天更新到Xcode 7,但最初在Xcode 6中添加了启动图像,但几个月前添加了徽标图像(也在Xcode 6中添加)。



我查看了json文件中的徽标图像和启动图像,它们看起来格式相同。我还浏览了pbxproj文件,寻找差异,我看不到任何差异。



所以我想知道是否有人知道为什么启动屏幕可能不会显示我在Air 2上添加的这些新图像?我一直在阅读的有关未出现的图像的其他问题似乎与启动图像有关,或者与XIB文件中具有关联类的图像有关,这两种图像在这里似乎都不相关。

解决方案

我的解决方案就是确保在故事板中为UIImageView取消选中清除图形上下文框。只需更改它就可以为我修复它。
没有其他解决方案适合我。
来自


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.

解决方案

"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

这篇关于UIImageView在设备上的启动屏幕中丢失图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆