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

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

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

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


当前回答

我尝试清理项目,删除png,删除约束,但对我来说没有用。

我只是做了一个图像的副本和重命名的副本,然后删除旧的图像,并添加了新的图像(相同,与名称更改),我只是给了那个图像,它为我工作。

我也没有使用资产。Xcassets,使用文件夹中的图像。

其他回答

我也遇到过同样的问题。我尝试了不同的解决方案,但都无济于事。然后我意识到,只有当我直接将应用程序安装到设备中,应用程序仍然连接到xcode时,图像才不可见。如果我断开它,然后打开应用程序的图像是可见的预期。 这可能是一个xcode错误。

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),在图像视图>图像,删除图像扩展名(.png或.jpg) -这是诀窍

在设计屏幕上,它不会出现,但当你运行应用程序时,它会显示出来。

希望能有所帮助!

我的问题。

原因:我在拖拽到Xcode后重命名了图片。 解决方案:在拖拽到Xcode后不要重命名图像。这给理解Xcode带来了问题。在拖动或添加到Xcode之前重命名图像。

希望它能帮助你!

在投入了大量的时间后,我得到了解决方案:-

Step 1:- Quit Xcode
Step 2:- Delete the app from device/simulator
Step 3:- Restart your device (if you are using simulator then you have to quit simulator)
Step 4:- Clear all derived data 
Step 5:- Clear Bin
Step 6:- Open Xcode and relaunch the app, it will work