我正在尝试从我的启动屏幕中获得一个图像来显示为启动屏幕。故事板文件,但图像从不显示。我有标签显示良好,但图像不出现。
这是启动屏幕在启动屏幕中的外观。故事板文件:
然而,当我在模拟器(以及物理设备)上运行应用程序时,显示如下:
如您所见,标签“Test”显示良好,但图像没有显示。我真的不知道为什么会发生这种情况,我尝试的任何方法似乎都不起作用。如果任何人有任何关于如何解决这个问题的想法,这将是非常感激的。
我正在尝试从我的启动屏幕中获得一个图像来显示为启动屏幕。故事板文件,但图像从不显示。我有标签显示良好,但图像不出现。
这是启动屏幕在启动屏幕中的外观。故事板文件:
然而,当我在模拟器(以及物理设备)上运行应用程序时,显示如下:
如您所见,标签“Test”显示良好,但图像没有显示。我真的不知道为什么会发生这种情况,我尝试的任何方法似乎都不起作用。如果任何人有任何关于如何解决这个问题的想法,这将是非常感激的。
当前回答
我尝试了很多东西(这个线程似乎有一百万个想法,其中一半是相互冲突的)。我的问题是,当我重新启动设备和Xcode时,它会导致图像在应用程序的几个会话中显示,然后它会停止(我不知道为什么,但哇,这很烦人)。
过了无数个小时,我发现a。g的答案是正确的。我做错的一件事是我在xcassets中创建了一个新的图像集,但我仍然在使用故事板中的UIImageView中的图像名称,而不是使用图像集的名称。
为了澄清,你要做的是创建一个新的图像集,并将其命名为“Launch-Defaults”,然后将你的图像添加到它。然后,在故事板的UIImageView内部,你使用图像“Launch-Default”(不包括扩展,因为没有,因为这是一个图像集)。
When you do all of that, the image should actually appear correctly inside of your storyboard. Some people say the image will display blank if you don't use the extension (.jpg or .png), but I assume that is because they are not using the name of the image set. Others say you need to use an extension like .png or .jpg, but the key is to create the image set inside of xcassets and then use that image set inside of the storyboard. When done correctly, there should be no funkiness like an image not showing up or the Launch Screen only working some of the time (requiring a reboot).
其他回答
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
我也遇到过同样的问题。我尝试了不同的解决方案,但都无济于事。然后我意识到,只有当我直接将应用程序安装到设备中,应用程序仍然连接到xcode时,图像才不可见。如果我断开它,然后打开应用程序的图像是可见的预期。 这可能是一个xcode错误。
我尝试了很多东西(这个线程似乎有一百万个想法,其中一半是相互冲突的)。我的问题是,当我重新启动设备和Xcode时,它会导致图像在应用程序的几个会话中显示,然后它会停止(我不知道为什么,但哇,这很烦人)。
过了无数个小时,我发现a。g的答案是正确的。我做错的一件事是我在xcassets中创建了一个新的图像集,但我仍然在使用故事板中的UIImageView中的图像名称,而不是使用图像集的名称。
为了澄清,你要做的是创建一个新的图像集,并将其命名为“Launch-Defaults”,然后将你的图像添加到它。然后,在故事板的UIImageView内部,你使用图像“Launch-Default”(不包括扩展,因为没有,因为这是一个图像集)。
When you do all of that, the image should actually appear correctly inside of your storyboard. Some people say the image will display blank if you don't use the extension (.jpg or .png), but I assume that is because they are not using the name of the image set. Others say you need to use an extension like .png or .jpg, but the key is to create the image set inside of xcassets and then use that image set inside of the storyboard. When done correctly, there should be no funkiness like an image not showing up or the Launch Screen only working some of the time (requiring a reboot).
在我的案例中有两个问题解决了它:
似乎有1MB的图像大小限制;没有文档,但当我优化相同的图像从3MB到1MB以下,它工作。这是有意义的,因为操作系统希望启动屏幕尽可能轻。 操作系统确实积极缓存启动屏幕!为了看到我的启动屏幕变化,我必须每次重置模拟器:Device > Erase所有内容和设置