ios 启动屏幕故事板不显示图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36669325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:55:02  来源:igfitidea点击:

Launch Screen storyboard not displaying image

iosiphonexcode

提问by shadowarcher

I'm trying to get an image to display as the launch screen from my Launch Screen.storyboard file, however the image never displays. I have labels that show up fine, but the image doesn't appear.

我试图从我的 Launch Screen.storyboard 文件中获取一个图像作为启动屏幕显示,但是该图像永远不会显示。我有显示正常的标签,但图像没有出现。

This is how the launch screen looks in the Launch Screen.storyboard file: enter image description here

这是启动屏幕在 Launch Screen.storyboard 文件中的外观: enter image description here

However when I run the app on the simulator (as well as on the physical device) this is what shows up:

但是,当我在模拟器(以及物理设备上)上运行该应用程序时,会显示以下内容:

enter image description here

enter image description here

As you can see, the label "Test" shows up fine, however the image does not display. I'm really not sure why this is happening and nothing I try seems to work. If anyone has any ideas of how to fix this it would be greatly appreciated.

如您所见,标签“Test”显示正常,但图像不显示。我真的不确定为什么会发生这种情况,而且我尝试的任何方法似乎都不起作用。如果有人对如何解决此问题有任何想法,将不胜感激。

回答by Flexicoder

After restarting Xcode, cleaning the build and a number of the other suggestions on SO about this problem. What actually fixed it for me was a hard reboot of the device. (I wasted over an hour on this)

重新启动 Xcode 后,清理构建和一些关于此问题的其他建议。实际上为我修复的是设备的硬重启。(我浪费了一个多小时)

I suppose it just goes to show that the old saying have you turned it off and on again is still true for the latest gadgets!

我想这只是表明,对于最新的小工具来说,您是否将其关闭并再次打开这句老话仍然适用!

How to reboot iPhone XS or iPhone XS Max

如何重启 iPhone XS 或 iPhone XS Max

  1. Quickly press and release the Volume Up button
  2. Quickly press and release the Volume Down button
  3. Press and hold the Side Button until the Apple logo appears
  1. 快速按下并松开调高音量按钮
  2. 快速按下并松开降低音量按钮
  3. 按住侧边按钮直到出现 Apple 标志

回答by Tristan G

I was messing around with this for hours too. But i found the solution now. You need to add the image to your projectand also to the assets.xcassets via drag and drop.

我也在这个问题上折腾了好几个小时。但我现在找到了解决方案。您需要将图像添加到您的项目以及通过拖放操作添加到 assets.xcassets 中。

回答by Jakab Robert

Had the same issue, adding the image to the "Build Phases -> Copy Bundle Resources" fixed it for me.

有同样的问题,将图像添加到“构建阶段 - > 复制捆绑资源”为我修复了它。

回答by Vineesh TP

Follow below steps,

按照以下步骤,

  1. Remove application from the device
  2. Restart device
  3. Build again
  1. 从设备中删除应用程序
  2. 重启设备
  3. 重新构建

If not working, delete derived data. Xcode Preference->Locationtab->Derived data. Then do follow above steps.

如果不起作用,请删除派生数据。Xcode Preference->Locationtab->Derived data。然后按照上面的步骤操作。

回答by Jhonsore

It happened to me and makes me crazy, beyond get me lose some minutes 'til I figure it out.

它发生在我身上,让我发疯,除了让我失去几分钟,直到我弄清楚为止。

So, like was said before:

所以,就像之前说的:

  1. Import the desired image to your Xcode project (just drag and drop it)
  2. Change its Constraints and Alignment
  3. Update frames resolving Auto Layout issues
  4. In the Attributes inspector tab menu (generally in right corner menu xCode), on Image view > Image, remove image extension (.png or .jpg) - that's the trick
  1. 将所需的图像导入您的 Xcode 项目(只需拖放即可)
  2. 改变它的约束和对齐
  3. 更新框架以解决自动布局问题
  4. 在属性检查器选项卡菜单(通常在右上角菜单 xCode)中,在图像视图 > 图像上,删除图像扩展名(.png 或 .jpg) - 这就是诀窍

On the design screen, it will not appear, but when you run your app, it will be shown.

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

I hope it can help!

我希望它能有所帮助!

回答by Crashalot

Very frustrating. Solution that finally worked:

非常令人沮丧。最终奏效的解决方案:

  1. Do hard reboot of device

  2. Delete app

  3. Install app from Xcode

  1. 硬重启设备

  2. 删除应用

  3. 从 Xcode 安装应用程序

回答by shumin

At last, restart the phoneworks for me!!

最后,重启手机对我有用!!

I have spent hours on this issue. Had tried change the images name, delete the whole image assets, modify info.plist, restart Xcode and even tried to set all the attributes of the images(which you can tell how desperate I was).

我在这个问题上花了几个小时。曾尝试更改图像名称,删除整个图像资产,修改 info.plist,重新启动 Xcode,甚至尝试设置图像的所有属性(您可以看出我有多绝望)。

回答by Reinier Melian

This issue is related to the Assets.xcassetsto fix it you must add the image as resource but not in the xcassetsfolder and then should work just fine

此问题与Assets.xcassets相关以修复它您必须将图像添加为资源但不在xcassets文件夹中,然后应该可以正常工作

回答by Tarek

In my case, resetting content and settings for simulator fixed the problem.

就我而言,重置模拟器的内容和设置解决了这个问题。

回答by A.G

I faced the same problem.

我遇到了同样的问题。

  1. Add an new imageset to XcodeAssets.
  2. Add images to to the imageset.
  3. Add image view to launch screen and set your imageset as image
  4. On Imageview's attributes inspector, uncheck 'clears graphics context'
  5. Clean the build folder and run again.
  1. 将新图像集添加到 XcodeAssets。
  2. 将图像添加到图像集中。
  3. 将图像视图添加到启动屏幕并将您的图像集设置为图像
  4. 在 Imageview 的属性检查器上,取消选中“清除图形上下文”
  5. 清理构建文件夹并再次运行。

enter image description here

enter image description here