简体   繁体   English

Splash Image命名冲突和PNG压缩错误

[英]Splash Image naming clash and PNG crush error

I am adding splash images in one of my Universal projects using xCode5. 我正在使用xCode5在我的一个Universal项目中添加启动图像。

When I add splash image for iPhone Non-Retina (iOS 6.1 or prior) , xCode asks me to rename the image to Default.png (Good enough) 当我为iPhone Non-Retina (iOS 6.1 or prior)更早版本iPhone Non-Retina (iOS 6.1 or prior)添加启动图像时,xCode要求我将图像重命名为Default.png(足够好)

I add all other images for iPhone. 我为iPhone添加了所​​有其他图像。

When I add splash image for iPad Portrait Non-Retina (iOS 6.1 or prior) , xCode again asks me to rename the file to Default.png and places it in a sub-directory. 当我为iPad Portrait Non-Retina (iOS 6.1 or prior)更早版本iPad Portrait Non-Retina (iOS 6.1 or prior)添加启动图像时,xCode再次要求我将文件重命名为Default.png并将其放在子目录中。

Now when I try to build the project, it gives the PNG Crush error due to same file names. 现在,当我尝试构建项目时,由于文件名相同,它会产生PNG Crush错误。

Here is the exact error: While reading /Volumes/iosWorkspace/projectName/projectName/Default@2x.png pngcrush caught libpng error: Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure 这是确切的错误: While reading /Volumes/iosWorkspace/projectName/projectName/Default@2x.png pngcrush caught libpng error: Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure

The images should be called: 应该调用图像:

iPhone: 苹果手机:

  • Default.png 为Default.png
  • Default@2x.png Default@2x.png
  • Default-568h@2x.png Default-568h@2x.png

iPad: iPad的:

  • Default-Portrait.png 默认Portrait.png
  • Default-Portrait@2x.png Default-Portrait@2x.png
  • Default-Landscape.png 默认Landscape.png
  • Default-Landscape@2x.png Default-Landscape@2x.png

--- or you can use "LandscapeLeft" and "LandscapeRight" & "PortraitUpsideDown" ---或者你可以使用“LandscapeLeft”和“LandscapeRight”和“PortraitUpsideDown”

There's usually no need to add a "~ipad" at the end because you can only choose landscape or portrait loading images for the iPad. 通常不需要在末尾添加“~ipad”,因为您只能为iPad选择横向或纵向加载图像。 If you do really need to specify device specific loading images then you can do it, but use a tilde (~) instead of a hyphen (-). 如果你真的需要指定设备特定的加载图像,那么你可以这样做,但使用波浪号(〜)而不是连字符( - )。

Apple's documentation on it is here: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/App-RelatedResources/App-RelatedResources.html Apple的文档在这里: https//developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/App-RelatedResources/App-RelatedResources.html

And make sure you get the "D" in uppercase otherwise it will work on the simulator but not the device. 并确保你得到大写的“D”否则它将在模拟器上工作,但不在设备上。

It seems that in xCode5 order of adding splash images matters. 似乎在xCode5中添加启动图像的顺序很重要。 If no splash image is added and I directly add an image for iPad non-Retina, xCode forces me to renames it to Default.png which is meant to be for iPhone Splash Image. 如果没有添加启动图像,我直接为iPad非Retina添加图像,xCode强制我将其重命名为Default.png ,这适用于iPhone Splash Image。

I took backup of all the splash images, deleted them from my project and added them again in the order as shown bellow: 我对所有启动图像进行了备份,将它们从我的项目中删除,然后按顺序再次添加它们,如下所示:

在此输入图像描述

Then the xCode didn't force me to rename the iPad Splash Image to Default.png 然后xCode没有强迫我将iPad Splash Image重命名为Default.png

Another problem (that was actually causing the pngcrush error) was that I had two images with the same name in my project. 另一个问题(实际上导致了pngcrush错误)是我的项目中有两个同名的图像。 One on root directory and one in sub-directory. 一个在根目录上,一个在子目录中。 As I explained in the question, this was because xCode was forcefully renaming the two images to the same name. 正如我在问题中解释的那样,这是因为xCode强行将两个图像重命名为相同的名称。

There must be two possibilities, 必须有两种可能性,

Your image is corrupted. 您的图片已损坏。 Resave it as .png from photoshop or take new one. 从photoshop中将其重新保存为.png或重新拍摄。 Check whether you have added two/ multiple references in Xcode or not. 检查您是否在Xcode中添加了两个/多个引用。 If yes, then delete old references. 如果是,则删除旧引用。

May be help you. 可能会帮到你。 Check Alpha Channel property as shown in attached screenshot. 检查Alpha Channel属性,如附带的屏幕截图所示。 It should be YES if its NO . 如果NO那应该是YES 在此输入图像描述

Apparently there were two identical files which caused this problem. 显然有两个相同的文件导致了这个问题。 Deleted the duplicate and the error went away. 删除了副本,错误就消失了。 Tested this on iOS8.1 with Xcode 6.1 在带有Xcode 6.1的iOS8.1上进行了测试

Credit goes to the answer from this thread iPad: PNG Crush error 信用来自这个线程的答案iPad:PNG Crush错误

It usually happens when you rename a file of different format say jpg to png. 当您重命名不同格式的文件(例如jpg to png.时,通常会发生这种情况jpg to png.

Create a new .png and use it. 创建一个新的.png并使用它。

  • Open your new image in preview. 在预览中打开新图像。
  • cmd+a and select a entire contents of the image. cmd + a并选择图像的整个内容。
  • Click on file >select new from clipboard. 单击文件>从剪贴板中选择新建。
  • Save the file specifying the format type png and use it. 保存指定格式类型png的文件并使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM