简体   繁体   English

iOS显示有关PNG图像的一些错误

[英]iOS Show some error about PNG image

I am using Xcode 4.3.3, I already tried to build my app before and it run. 我正在使用Xcode 4.3.3,我之前已经尝试构建我的应用程序并运行它。 But now I arranged my files inside my project's folder, grouped them by 'button' , 'icon' , 'background'... I also copied some resources/images in other folder put them in order but now I'm in trouble. 但现在我将我的文件安排在我项目的文件夹中,按“按钮”,“图标”,“背景”分组......我还在其他文件夹中复制了一些资源/图像,但是现在我遇到了麻烦。

Im trying to build my app again in Xcode, I found a CopyPNG Error: 我试图在Xcode中再次构建我的应用程序,我发现了一个CopyPNG错误:

Can't find /Users/vella/Desktop/Sample/res/2.png Command /Users/vella/Desktop/installer/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng failed with exit code 1 找不到/Users/vella/Desktop/Sample/res/2.png命令/Users/vella/Desktop/installer/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/ iPhoneOS Build System Support.xcplugin / Contents / Resources / copypng失败,退出代码为1

Now, I don't know if I missed some png files. 现在,我不知道是否错过了一些png文件。 I also read some answers like I should save PNG files as NOT INTERLACED or there is a PNG file that is corrupted. 我还读了一些答案,比如我应该将PNG文件保存为NOT INTERLACED或者有一个已损坏的PNG文件。 How will I know what PNG file is missing or corrupted? 我怎么知道PNG文件丢失或损坏了什么?

检查是否已将2.png添加到项目文件夹中。在将项目添加到项目中时,单击“将项目复制到目标组文件夹”复选框。如果您的png文件已损坏,则项目中将为红色。

Clean up the png file in your project and re-import it: 清理项目中的png文件并重新导入:

  1. Delete (backup) that file in project navigator. 在项目导航器中删除(备份)该文件。 Just delete and move file to trash can. 只需删除并将文件移至垃圾桶即可。
  2. Go to project Build Phases: i. 转到项目构建阶段:i。 Select the root project ii. 选择根项目ii。 Select TARGETS iii. 选择TARGETS iii。 Select Build Phases tag iv. 选择Build Phases tag iv。 Expand Copy Bundle Resources list If you see the file you just deleted still exists (maybe in red), delete it 展开“复制包资源”列表如果您看到刚刚删除的文件仍然存在(可能为红色),请将其删除
  3. Re-import the file again 再次重新导入文件

This worked for me. 这对我有用。

You have to save your PNG files as NOT INTERLACED. 您必须将PNG文件保存为NOT INTERLACED。 For example, bu using Photoshop, go to menu File->Save For Web and Devices. 例如,使用Photoshop,转到菜单文件 - >存储为Web和设备。 Unchecked the box of 'Interlaced' and save the file. 取消选中“隔行扫描”框并保存文件。 Usually interlaced box is unchecked already. 通常隔行扫描的盒子已经取消选中。 Hope that helps 希望有所帮助

Yep, Add it again and this time dont arrange or rearrange any stuff in your resources folder. 是的,再次添加它,这次不要安排或重新排列资源文件夹中的任何内容。 Also give specific naming to the images so that its easy for you to remember and implement them later in ur project. 还要给图像赋予特定的命名,以便您在以后的项目中轻松记住并实现它们。

I just had the same problem. 我刚遇到同样的问题。 I always do the same thing to add images to my projects but I never had a problem like this before. 我总是做同样的事情来添加图像到我的项目,但我从来没有像这样的问题。

I found in the error message that, the image path that Xcode was trying to find the image was wrong. 我在错误消息中发现,Xcode试图找到图像的图像路径是错误的。 The path that Xcode is searching was like " ...../My Project Folder/images/favourites.png" but the correct path is like "...../My Project Folder/myProjectName/images/favourites.png". Xcode搜索的路径就像“..... / My Project Folder / images / favourites.png”,但正确的路径就像是“..... /我的项目文件夹/ myProjectName / images / favourites.png” 。 To solve this, I create a folder with path " ...../My Project Folder/images", then I backed up my images and deleted all of them from project window and selected "move to trash". 为了解决这个问题,我创建了一个路径为“..... /我的项目文件夹/图像”的文件夹,然后我备份了我的图像并从项目窗口中删除了所有图像并选择了“移动到垃圾箱”。 I copied and pasted the images from my backup folder to this new folder. 我将备份文件夹中的图像复制并粘贴到此新文件夹中。 Then I drag-dropped them to "Supporting Files" and select "Copy items into destination group's folder (if needed)". 然后我将它们拖放到“支持文件”并选择“将项目复制到目标组的文件夹(如果需要)”。 Finally I cleaned the project and run it. 最后我清理了项目并运行它。 It worked for me. 它对我有用。 Good luck. 祝好运。

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

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