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

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

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

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


当前回答

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:

其他回答

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:

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

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

如何重启iPhone XS或iPhone XS Max

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

将图像作为常规文件导入对我来说很有效。不要从资产目录中添加图像!

此问题与资产相关。Xcassets修复它,你必须添加图像作为资源,但不是在Xcassets文件夹,然后应该工作得很好

我的第一个错误是,我创建了一个普通的.storyboard,重命名它,并在项目设置中将其定义为launchscreen。在这个案子里,我的形象有问题。在这种情况下,似乎有些设置缺失了,所以我只是通过file->new创建了一个新文件,并直接选择“启动屏幕”,然后它就工作了。

此外,我还考虑到,由于某些原因,布局限制在启动屏幕中不受支持。也许一开始是这样的,不确定,但现在约束应该起作用了。

也许这对任何人都有帮助。