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

当我启动应用程序时,UILabel和logo图像显示正确,但如果我在带有iOS9的iPad Air 2上运行应用程序,启动图像就不能显示。我在运行iOS8的Air和Mini上进行了测试,在iPad 2、iPad Air和iPad Air 2的iOS9模拟器上进行了测试,图像在所有这些模拟器上都显示正确。

我运行了一些基本的故障排除,看看我是否能找出发生了什么,但我还没能解决它,我能看到的图像之间的唯一区别是,工作和一个失败的是,当我添加到资产…

以下是我所知道的:

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.

这最后三个步骤使我相信,在项目文件生命周期的某一点之后添加的图像存在一些问题。当我昨天更新到Xcode 7时,splash图像最初是在Xcode 6中添加的,但logo图像(也添加到Xcode 6中)是在几个月前添加的。

我已经查看了logo图像和splash图像的json文件,它们似乎具有相同的格式。我还浏览了pbxproj文件,寻找不同之处,但我找不到任何不同之处。

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


当前回答

对我有帮助的是:

将“启动屏幕文件”更改为另一个xib 运行应用程序 把xib改回来

同样重要的是:检查你的is xib是否在另一个标签中打开,这也可能导致它!

其他回答

许多其他答案建议重新启动设备和/或重建和/或重新安装是解决方案。

虽然这些答案对我们中的一些人有用,但它们起作用的原因是应用程序被迫“重拍”或“重建”缓存的快照。

应用程序使用缓存快照在支持数据加载到内存之前呈现图像,包括包含故事板图像的资产目录。

@jaga的这个SO回答提供了解决方案,但不是原因,为什么设备上的启动屏幕上没有UIImageViews(但在模拟器中没有)。

背景

最近,我尝试在“启动屏幕”中使用自定义字体。故事板”文件。

在阅读@TimCamber的SO回答后,我无法弄清楚原因,这促使我做了更多的研究和测试。

自定义字体没有包含在我的启动屏幕故事板文件中的原因与资产目录中的图像没有包含的原因相同……

该应用程序准备从你的启动屏幕故事板文件的应用程序的启动屏幕的肖像和景观快照,(目前)保存在你的应用程序包这里:

/ Library / Caches Snapshots / < < app_bundle > > /和 / Library / Caches Snapshots / < < app_bundle > > downscaled /。

这个过程在加载任何支持文件(包括任何自定义字体和资产目录)之前完成。

解决方案

正如上面提到的@jaga的解决方案,字面上所需要的是:

(老派)添加一个图像文件(.PNG)到你的应用程序的包(正如你可以从下面的截图看到的,我添加了图像子目录下的支持文件子目录下的图像文件),和

在启动时在你的UIImageView对象中引用那个图像 屏幕故事板文件…

把它关掉,然后再打开。

说真的,重启设备——这就是我解决问题的方法。

以下是不起作用的方法:

清洁DerivedData。 清理项目。 从设备上卸载应用程序。 重新启动Xcode。 重新启动计算机。

年长的观察:

就像其他的一样,它:

在模拟器中工作良好 曾在iPhone 5S、iPad Air等设备上工作 没有代码更改(通过git reset -hard HEAD验证),但停止工作。

我记得触发它停止工作的第一个构建是在iPhone运行时拔掉电源。(不确定这是否相关。)

然而,git重置没有修复它(结合所有干净的步骤不工作)告诉我这必须被缓存到其他地方。很有可能在某个。gitignored文件中?(我在Xcode项目中使用Git忽略文件)

有一种解决方法适用于一个UIImageView(在有三个UIView的UIView中),但不适用于其他UIView,那就是将图像放入.xcassets文件中。恢复到普通图像文件并不能撤消修复。(真的感觉像是缓存错误。)

更新:见顶部重新启动设备是什么修复它。我感觉设备本身缓存了错误的位图数据。

雷达:http://openradar.appspot.com/23534818

从左边的菜单选择你的图像文件,从右边的工具菜单选择“显示文件检查器”。在目标会员下,确保你的目标已被选中。我添加了选择目标的图像,但我不知道为什么它没有被选择。我尝试了所有的解决方案,重新启动,删除等,没有一个工作。这个方法奏效了。希望它能帮助到其他人。

我也看到了同样的问题。重新启动设备(iPhone 6)并重新构建应用程序到设备是唯一修复它的方法。我尝试了许多其他的技巧和建议,但都不起作用。只有重启+重建才有帮助。

对我有用的是选择“重置内容和设置”……从模拟器菜单