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

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

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

如您所见,标签“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时,图像才不可见。如果我断开它,然后打开应用程序的图像是可见的预期。 这可能是一个xcode错误。

我也面临同样的问题。

添加一个新的图像集到XcodeAssets。 将图像添加到映像集中。 添加图像视图,以启动屏幕和设置您的imageset为图像 在Imageview的属性检查器中,取消选中“清除图形上下文” 清理生成文件夹并再次运行。

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安装app