无法让应用程序图标在 Xcode 6 中工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25778522/
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
Cannot get app icons to work in Xcode 6
提问by Brian Rak
I cannot for the life of me get this to work. Here's what I'm doing:
我这辈子都无法让它发挥作用。这是我在做什么:
- Create a brand new project for iPhone.
- In Project > General, project is already set to get app icon from the default asset catalog.
- Go into the asset catalog > AppIcon and drop in images as appropriate.
- Build and run. No icon.
- Check Project > Build Settings > Asset Catalog App Icon Set Name. It is correctly set to AppIcon.
- Check the images.xcassets file and make sure it has the right target membership.
- Check Project > Build Phases > Copy Bundle Resources and verify that images.xcassets is in there.
- 为 iPhone 创建一个全新的项目。
- 在 Project > General 中,project 已经设置为从默认资产目录中获取应用程序图标。
- 进入资产目录 > AppIcon 并根据需要放入图像。
- 构建并运行。没有图标。
- 检查项目 > 构建设置 > 资产目录应用程序图标集名称。它已正确设置为 AppIcon。
- 检查 images.xcassets 文件并确保它具有正确的目标成员资格。
- 检查 Project > Build Phases > Copy Bundle Resources 并验证 images.xcassets 在那里。
Still nothing. I am going INSANE. Someone please tell me I forgot a checkbox somewhere. Please?
依然没有。我要疯了。有人请告诉我我忘记了某处的复选框。请?
采纳答案by Brian Rak
The problem was with the images. I haven't been able to figure out exactly what was wrong with them. Resaving them with a different editor caused them to start working in my project.
问题出在图像上。我一直无法弄清楚他们到底出了什么问题。使用不同的编辑器重新保存它们使它们开始在我的项目中工作。
In case it helps anyone, these were the details of my scenario:
如果它可以帮助任何人,这些是我的场景的详细信息:
- I created the images programmatically using Inkscape.
- The files were all 32-bit PNGs.
- I confirmed by examining the binary files that interlacing was turned off, as Apple recommends.
- Resaving as 32-bit PNGs using Fireworks resulted in working files.
- I compared the good and bad files and only the headers were different. I'm not sure what the poisonous chunk was, but I did notice that the
pHYs
dimensions were different between the good and bad files (good:00 00 0B 12
, bad:00 00 0B 13
, which both correspond to 72 dpi). Obviously DPI shouldn't matter here, but I do vaguely remember a case where I had trouble with images that didn't have a certain DPI written into them in the past.
- 我使用 Inkscape 以编程方式创建了图像。
- 这些文件都是 32 位 PNG。
- 正如 Apple 建议的那样,我通过检查二进制文件确认了隔行扫描已关闭。
- 使用 Fireworks 重新保存为 32 位 PNG 会生成工作文件。
- 我比较了好文件和坏文件,只有标题不同。我不确定有毒块是什么,但我确实注意到
pHYs
好文件和坏文件之间的尺寸不同(好:00 00 0B 12
,坏:00 00 0B 13
,都对应于 72 dpi)。显然 DPI 在这里无关紧要,但我依稀记得有一个案例,我在处理过去没有写入特定 DPI 的图像时遇到问题。
At any rate, I dearly hope this saves someone else some hair pulling.
无论如何,我非常希望这可以为其他人节省一些麻烦。
回答by Victor Ranu
- Make sure under Settings > General > App Icons and Launch Images that App Icons Source is set to AppIcon
- Under Images.xcassets include the image files with the correct dimensions (refer to image below)
- Your icon must be a .png, & you must follow sizing according to this documentation: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
- 确保在 Settings > General > App Icons and Launch Images 下,App Icons Source 设置为 AppIcon
- 在 Images.xcassets 下包括具有正确尺寸的图像文件(参考下图)
- 您的图标必须是 .png,并且您必须根据此文档调整大小:https: //developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
In case the link should die it goes something like this (more sizing constraints for settings icon, toolbar and navigation bar icon, tab bar icon, etc..):
如果链接应该死,它会像这样(设置图标、工具栏和导航栏图标、标签栏图标等的更多大小限制。):
App icon sizing for iPhone 6 Plus (@3x): 180x180
app icon sizing for iPhone6 and iPhone5(@2x): 120x120
iPhone 6 Plus 的应用程序图标大小 (@3x):180x180
iPhone6 和 iPhone5 的应用程序图标大小 (@2x):120x120
app icon sizing for iPhone 4s (@2x): 120x120
iPhone 4s 的应用程序图标大小 (@2x):120x120
app icon sizing for iPad and iPadmini(@2x): 152x152
iPad 和 iPadmini 的应用程序图标大小(@2x):152x152
回答by coolio
In case someone else runs into this again: I had trouble getting icons to work because the asset catalog was not in the root resource folder but in a subfolder, that's obviously not allowed for icons (Xcode 7)
如果其他人再次遇到这个问题:我无法使图标正常工作,因为资产目录不在根资源文件夹中,而是在子文件夹中,这显然不允许图标(Xcode 7)
回答by Andrew Smith
My project managed to pick up an images.xcassets file that was not included int the target's membership. I have multiple xcassets files, so I looked through them in the organizer to find the correct file, and checked its box in the Target Membership panel. Work now.
我的项目设法获取了一个未包含在目标成员资格中的 images.xcassets 文件。我有多个 xcassets 文件,所以我在组织者中查看它们以找到正确的文件,并在 Target Membership 面板中选中了它的框。在工作,在忙。
回答by Rog182
After changing some code, I noticed the app icon stopped working. I looked at the diff, and in the YourProject.xcodeproj/project.pbxproj file, Xcode changed a line from
更改一些代码后,我注意到应用程序图标停止工作。我查看了差异,在 YourProject.xcodeproj/project.pbxproj 文件中,Xcode 从
24E9FAB41A9C9E410054E235 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
to
到
24E9FAB41A9C9E410054E235 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Images.xcassets; sourceTree = "<group>"; };
I opened up the file in a text editor, changed the lastKnownFileTypeback to folder.assetcatalog, rebuilt the app, and the app icon showed up again.
我在文本编辑器中打开文件,将lastKnownFileType改回folder.assetcatalog,重建应用程序,应用程序图标再次出现。
回答by Apostolos Apostolidis
Had the same problem and the reason for that was which application was used for creating the app icons. In particular they failed to appear when generated by Asset Generator but were successful when using Icon Set Creator (both are OS X desktop applications)
有同样的问题,原因是哪个应用程序用于创建应用程序图标。特别是它们在 Asset Generator 生成时没有出现,但在使用 Icon Set Creator 时成功(都是 OS X 桌面应用程序)