我正在尝试从我的启动屏幕中获得一个图像来显示为启动屏幕。故事板文件,但图像从不显示。我有标签显示良好,但图像不出现。

这是启动屏幕在启动屏幕中的外观。故事板文件:

然而,当我在模拟器(以及物理设备)上运行应用程序时,显示如下:

如您所见,标签“Test”显示良好,但图像没有显示。我真的不知道为什么会发生这种情况,我尝试的任何方法似乎都不起作用。如果任何人有任何关于如何解决这个问题的想法,这将是非常感激的。


当前回答

You have to make sure that the file name of your image has a format like .png or .jpg at the end otherwise it will not work. Also, before adding your image, you have to make sure that the image file is in your "Assets.xcassets" folder within your project. This can be done with a simple drag and drop. Also, make sure when you've added your image to your storyboard that the image name in the top left also matches the real image file name. I would try looking into Constraints too. Hope this helps. Good luck with your App.

其他回答

这恰好是XCode/iOS中的缓存问题,但有一个简单的修复方法:在Assets中重命名文件。Xcassets,这样缓存就会重新生成。

在尝试了几个StackOverflow线程后,以下是对我有效的方法:

使用。png格式 不要将它包括在您的资产目录中。将它直接添加到项目的层次结构中,就像添加任何源文件一样。 在图像视图中,加载图像及其扩展。例如:launch_app_image.png

(可能需要清理产品或衍生数据来更新,但我不需要)

在我的情况下,重置模拟器的内容和设置解决了这个问题。

You have to make sure that the file name of your image has a format like .png or .jpg at the end otherwise it will not work. Also, before adding your image, you have to make sure that the image file is in your "Assets.xcassets" folder within your project. This can be done with a simple drag and drop. Also, make sure when you've added your image to your storyboard that the image name in the top left also matches the real image file name. I would try looking into Constraints too. Hope this helps. Good luck with your App.

在重新启动Xcode后,清理构建和一些关于这个问题的其他建议。对我来说,真正解决问题的是重新启动设备。(我在这上面浪费了一个多小时)

我想这只是表明,老话说你关闭了它,然后再打开它仍然适用于最新的小玩意!

如何重启iPhone XS或iPhone XS Max

快速按下并释放音量增大按钮 快速按下并释放音量调低按钮 按住侧边键,直到苹果logo出现