我正在尝试从我的启动屏幕中获得一个图像来显示为启动屏幕。故事板文件,但图像从不显示。我有标签显示良好,但图像不出现。
这是启动屏幕在启动屏幕中的外观。故事板文件:
然而,当我在模拟器(以及物理设备)上运行应用程序时,显示如下:
如您所见,标签“Test”显示良好,但图像没有显示。我真的不知道为什么会发生这种情况,我尝试的任何方法似乎都不起作用。如果任何人有任何关于如何解决这个问题的想法,这将是非常感激的。
我正在尝试从我的启动屏幕中获得一个图像来显示为启动屏幕。故事板文件,但图像从不显示。我有标签显示良好,但图像不出现。
这是启动屏幕在启动屏幕中的外观。故事板文件:
然而,当我在模拟器(以及物理设备)上运行应用程序时,显示如下:
如您所见,标签“Test”显示良好,但图像没有显示。我真的不知道为什么会发生这种情况,我尝试的任何方法似乎都不起作用。如果任何人有任何关于如何解决这个问题的想法,这将是非常感激的。
当前回答
我有这个问题后,添加图像到项目和射击设备的问题解决了
其他回答
对我来说,这不仅仅是重启设备那么简单。 我的发射图像存储在其他资产(其他Pods)。
不得不将图像移动到应用程序项目的资产。 然后重启了我的设备。(首先检查模拟器,它应该工作)。 然后就成功了。
图片可以是png/pdf格式,单比例或不重要。
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.
在投入了大量的时间后,我得到了解决方案:-
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
在我的情况下,重置模拟器的内容和设置解决了这个问题。
有同样的问题,将图像添加到“构建阶段->复制捆绑资源”为我修复了它。