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

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

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

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


当前回答

最后,重启电话对我有用!!

我在这个问题上花了好几个小时。尝试过更改图像名称,删除整个图像资产,修改信息。plist,重新启动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后不要重命名图像。这给理解Xcode带来了问题。在拖动或添加到Xcode之前重命名图像。

希望它能帮助你!

I just figured this out. My launch image was not showing up, I get a white screen when launching on a device (iPhone 6, 7+) or testFlight. Fix: Renamed "Landing_screen.png" to just "Landing_screen" removing .png part. The image icon in Xcode changed to white icon and in the launch screen storyboard the image appears as a question mark now. The Launch image now appears and not the white screen. My Setup: I am using Swift 3.1 with Xcode 8.3.1. In LaunchScreen.storyboard I added a simple image view and stretched the image to fit the view controller. I set auto layout constraints Top/Bottom/Leading/Trailing space to superview to 0 - see image below:

我陷入了同样的问题,感谢下面的参考,我能够解决这个问题

https://developer.apple.com/forums/thread/19759?answerId=75438022#75438022

虽然没有必要在为imageview选择图像时更改图像名称和删除扩展名,但我只是简单地创建了一个名为resources的文件夹,并将我的图像添加到该文件夹中,因为我认为将图像直接放入根文件夹中并不好

希望这能有所帮助。

调试快乐!