iOS 启动屏幕资产目录不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19484948/
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 02:27:31  来源:igfitidea点击:

iOS Launch Screen Asset Catalog not working

iphoneiosxcode

提问by zburns12

I believe I am making a silly mistake. But I cannot figure it out.

我相信我犯了一个愚蠢的错误。但我想不通。

I have an image named Default.png that I have added to my project. Now when I go to General and then Launch Images I drag and drop this Default.png to the 2x window for my app. When I go to build the project and try it, I get this error:

我有一个名为 Default.png 的图像,已添加到我的项目中。现在,当我转到 General 然后 Launch Images 时,我将此 Default.png 拖放到我的应用程序的 2x 窗口中。当我去构建项目并尝试它时,我收到此错误:

"The launch image set named "LaunchImage" did not have any applicable content."

“名为“LaunchImage”的启动图像集没有任何适用的内容。”

What's the problem here? I've also seen that simply dragging and dropping the Default.png should do it, but I think that's for older versions.

这里有什么问题?我还看到只需拖放 Default.png 就可以做到,但我认为这是针对旧版本的。

Any ideas?

有任何想法吗?

Thanks

谢谢

采纳答案by emreoktem

Search for LaunchImage keyword in your .plist file and delete it. Then, try assigning the image again by dragging as you already did before...

在 .plist 文件中搜索 LaunchImage 关键字并将其删除。然后,尝试通过拖动再次分配图像,就像之前所做的那样......

回答by Jasen

This case raised in Xcode 5.0 + iOS 7. Apple use Images.xcassets to group App Icons, App Launch (Default) Images in Xcode 5.0 + iOS 7.

这种情况在 Xcode 5.0 + iOS 7 中出现。Apple 使用 Images.xcassets 对 Xcode 5.0 + iOS 7 中的应用程序图标、应用程序启动(默认)图像进行分组。

For solving the problem of Asset Catalog Compiler Error The launch image set named "LaunchImage" did not have any applicable content.

用于解决资产目录编译器错误的问题名为“LaunchImage”的启动图像集没有任何适用的内容。

Approach: Putting suitable size of images into LaunchImage. For example: Should be 640x960 dimensioning in iPhone Portrait iOS7 2x. Should be 640x1136 dimensioning in iPhone Portrait iOS 7 R2.

方法:将合适大小的图片放入LaunchImage中。例如:iPhone Portrait iOS7 2x 中的尺寸应为 640x960。iPhone Portrait iOS 7 R2 中的尺寸应为 640x1136。

Reference from iOS App Programming Guide:

iOS App 编程指南中的参考:

Create and Set iOS Launch Images

创建和设置 iOS 启动图像

Launch images are displayed while your app is launching on iOS. A launch image matching the device resolution appears as soon as the user taps your app icon.

当您的应用程序在 iOS 上启动时会显示启动图像。只要用户点击您的应用程序图标,就会出现与设备分辨率匹配的启动图像。

App Launch (Default) Images

应用启动(默认)图像

Specify the launch images for your app in your Xcode project settings. In Xcode 5.0, specify these images on the General tab of your project settings; in older versions of Xcode, this tab may have a different name. Xcode places your launch image files at the top-level of the app bundle and configures other project settings as appropriate. Specifically, Xcode adds the UILaunchImages key to your app's Info.plist file automatically if your app runs on iOS 7 or later. That key tells the system the name of your app's launch image files. For earlier versions of iOS, the system uses the launch image filenames to decide which image to load.

在 Xcode 项目设置中为您的应用程序指定启动图像。在 Xcode 5.0 中,在项目设置的 General 选项卡上指定这些图像;在旧版本的 Xcode 中,此选项卡可能具有不同的名称。Xcode 将您的启动图像文件放在应用程序包的顶层,并根据需要配置其他项目设置。具体来说,如果您的应用程序在 iOS 7 或更高版本上运行,Xcode 会自动将 UILaunchImages 键添加到您应用程序的 Info.plist 文件中。该键告诉系统您的应用程序的启动图像文件的名称。对于早期版本的 iOS,系统使用启动图像文件名来决定加载哪个图像。

回答by prodeveloper

The same error has been resolved by adding the exact sizes of launch images for different iOS devices.

通过为不同的 iOS 设备添加启动图像的确切大小,已解决了相同的错误。

回答by kakubei

I had this problem as well. Make sure of a couple of things:

我也有这个问题。请确保以下几点:

  1. Aspect Ratio is what Apple expects, in other words square
  2. The sizes are correct, 60pt (for example) should be 60x60
  3. 60pt @2x should be 120x120
  1. 纵横比是苹果所期望的,换句话说就是正方形
  2. 尺寸正确,60pt(例如)应该是 60x60
  3. 60pt @2x 应该是 120x120

After I fixed the sizes the app compiled without errors but I think the most important thing is the aspect ratio.

在我修复了应用程序编译没有错误的大小之后,但我认为最重要的是纵横比。

回答by Eliot

I tried everything here, deleted the .app and rebuilt each time, and nothing worked. I finally got fed up and switched back to the old style of launcher image specification (Project Settings Window -> General -> Launch Images -> Source -> Don't use asset catalogs.) That worked!

我在这里尝试了所有方法,删除了 .app 并每次都重新构建,但没有任何效果。我终于受够了并切换回旧样式的启动器图像规范(项目设置窗口 -> 常规 -> 启动图像 -> 源 -> 不要使用资产目录。)成功了!

回答by neowinston

In my case, with Xcode 7, the Images.xcassetswas missing from the Build Phases, under Copy Bundle Resources. Then I just added it manually and the problem was gone.

在我的情况下,使用 Xcode 7 Images.xcassets,在复制捆绑资源下的构建阶段中丢失了。然后我只是手动添加它,问题就消失了。

回答by jomafer

Check and compare carefully if your image size matches the expected size. In my case I was using a wrong size, but when correcting the project built fine.

仔细检查并比较您的图像尺寸是否与预期尺寸相符。在我的情况下,我使用了错误的尺寸,但是在纠正项目时构建得很好。

Check this attached image to see where you can compare them

检查此附加图像以查看可以比较它们的位置

回答by rkh

Try looking at the code for "LaunchImage" and rename it to "Default"

尝试查看“LaunchImage”的代码并将其重命名为“Default”