简体   繁体   English

iOS Launchscreen.storyboard图像未显示

[英]iOS Launchscreen.storyboard Image not showing

I am using Xcode 7 and Swift to create an iOS project. 我正在使用Xcode 7和Swift创建一个iOS项目。
My current problem is that my LaunchScreen.storyboard Image is not appearing when I launch a Run. 我当前的问题是启动运行时我的LaunchScreen.storyboard图像没有出现。

To my Project I did a File - New - File - iOS - User Interface - Launch Screen. 对于我的项目,我做了一个文件-新建-文件-iOS-用户界面-启动屏幕。 That added a Launchscreen.storyboard to my project. 这为我的项目添加了Launchscreen.storyboard。 I then set its Background to Black (so far, so good). 然后,将“背景”设置为“黑色”(到目前为止,效果很好)。 And I have the ViewController's "Use Size Classes" un-checked to preserve the visual sizing. 而且我未选中ViewController的“使用尺寸类”以保留视觉尺寸。

Now I added an ImageView to the View and set its Image file to my desired Logo png file. 现在,我在视图中添加了一个ImageView并将其Image文件设置为所需的Logo png文件。 All visually appears OK in the Development GUI. 在开发GUI中,所有外观均显示为OK。

But, when I launch the Run the Black screen momentarily appears before going to the subsequent screen, but the Logo does not appear on iPhone within the initial Launchscreen 但是,当我启动“运行黑色”屏幕时,会暂时转到下一个屏幕,但徽标不会在初始“启动”屏幕中出现在iPhone上

Obviously I am doing something wrong, but I do not know what. 显然我做错了事,但是我不知道怎么办。

I had exactly the same issue and images in my LaunchScreen.storyboard were not appearing on any devices. 我遇到了完全相同的问题,并且LaunchScreen.storyboard中的图像没有出现在任何设备上。 I solved it by removing the launch images (1x, 2x, 3x) from the asset catalog and dragging them right into the project hierarchy like in the olden times. 我通过从资产目录中删除启动图像(1x,2x,3x)并将其拖到项目层次结构中来解决了该问题,就像过去一样。 Additionally I had to explicitly add the image extension (.png) in IB. 另外,我必须在IB中显式添加图像扩展名(.png)。 After that everything worked fine including Auto Layout, etc. 之后,一切正常,包括“自动布局”等。

I'd start by restarting the device (or quitting the Simulator). 我将从重新启动设备(或退出模拟器)开始。 I think Springboard might be caching the storyboard file, such that even after the app is deleted and re-installed, it goes looking for the specific set of assets referenced in the original storyboard on launch. 我认为Springboard可能会缓存情节提要文件,以便即使删除并重新安装该应用程序后,它也会在启动时寻找原始情节提要中引用的特定资产集。 Restarting the device seems to make the image to show up, even without re-installing—I suspect because it clears Springboard's cache. 重新启动设备似乎可以显示该图像,即使不重新安装也可以。我怀疑是因为它清除了Springboard的缓存。

  • Delete Derived Data. 删除派生数据。
  • Delete app from Device/Simulator. 从设备/模拟器中删除应用。
  • Restart Device/Simulator and run app. 重新启动设备/模拟器并运行应用程序。

I resolved this exact issue by selecting the Launchscreen.storyboard then selecting the View Controller then opening up the Attribute Inspector and checking off the box that says "is initial View Controller". 我通过选择Launchscreen.storyboard,选择View Controller,然后打开Attribute Inspector并取消选中“是初始View Controller”的框来解决此确切问题。 Hopefully it helps somebody after all these years. 希望这些年来对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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