xcode 错误代码:无法加载从标识符为“com.bundle.identifier”的包中的笔尖引用的“image.png”图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20237739/
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
Error code: Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.bundle.identifier"
提问by user3040900
This question has been asked before and i have looked in all of the other stackoverflow topics for an answer, but i can't resolve the issue.
之前有人问过这个问题,我查看了所有其他 stackoverflow 主题的答案,但我无法解决这个问题。
My app works fine in the simulator for all platforms, but when i run the app on my device i get the error code: Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.bundle.identifier".
我的应用程序在所有平台的模拟器中运行良好,但是当我在我的设备上运行该应用程序时,我收到错误代码:无法加载从带有标识符“com.bundle.标识符”。


All of my pictures are .PNG files and i have used the storeboard to insert them in an imageView.
我所有的图片都是 .PNG 文件,我使用 storeboard 将它们插入到 imageView 中。
Program: Xcode 5
程序:Xcode 5
回答by Basheer_CAD
If you are using the image name without extension e.g. [UIImage imageNamed:@"myImage"];
then make sure that your image is of .png format, because Xcode will load only .png images without adding extension, otherwise you should use the name with extension [UIImage imageNamed:@"myImage.jpg"];and should work.
如果您使用没有扩展名的图像名称,例如,[UIImage imageNamed:@"myImage"];
那么请确保您的图像是 .png 格式,因为 Xcode 将仅加载 .png 图像而不添加扩展名,否则您应该使用带有扩展名的名称[UIImage imageNamed:@"myImage.jpg"];并且应该可以工作。
回答by ashNair
I had the same issue and I resolved it by selecting the check box to add it to app in Target Membership. So, select the image from the library, and then on the File Inspector, add it to the target. It worked for me, hope it works for you as well.
我遇到了同样的问题,我通过选中复选框将其添加到 Target Membership 中的应用程序来解决它。因此,从库中选择图像,然后在文件检查器上将其添加到目标。它对我有用,希望它也适用于你。
回答by Azik Abdullah
Delete that image from the project and move it to trash and then try re-adding that image to the project by checking copy items to destination's group folder check box clicked.
从项目中删除该图像并将其移至垃圾箱,然后通过选中已单击的将项目复制到目标组文件夹复选框,尝试将该图像重新添加到项目中。
This may be the reason for the issue for not loading the image in the device.
这可能是未在设备中加载图像的问题的原因。
回答by ChenXi
I resolved this issue by deleting the image named image.pngin my storyboard and it worked immediately. This image may also exists in your code or anywhere else.
我通过删除image.png我的故事板中命名的图像解决了这个问题,它立即生效。此图像也可能存在于您的代码中或其他任何地方。
回答by Enrico Susatyo
I got this problem when I accidentally added another Image set with the same name to Asset Catalog file. I renamed it after I realised the mistake, but it doesn't seem to work.
当我不小心将另一个具有相同名称的图像集添加到资产目录文件时,我遇到了这个问题。我在意识到错误后重新命名了它,但它似乎不起作用。
Removing the file and adding it again solves the problem.
删除文件并再次添加它可以解决问题。
回答by ThomasW
The nib (or ultimately the xib) that is the cause of the warning message is the one that is loaded when the message gets written. You then can look at the controls that use images in the inspector and find one where the image name is "Unknown image" (or perhaps "image.png" in your case). You can then clear this value by setting it to some value and then clearing out the value. Note that with UIButton you'll need to try the four different values of "State Config" (Default, Highlighted, Selected & Disabled) to see where the invalid reference might be hiding.
导致警告消息的笔尖(或最终的 xib)是写入消息时加载的笔尖。然后,您可以查看检查器中使用图像的控件,并找到图像名称为“未知图像”(或在您的情况下为“image.png”)的控件。然后,您可以通过将其设置为某个值然后清除该值来清除该值。请注意,使用 UIButton,您需要尝试“状态配置”的四个不同值(默认、突出显示、选定和禁用)以查看无效引用可能隐藏的位置。
回答by MQoder
Removing the reference and adding it again to the project did the job for me! you might need to clean the project.
删除引用并将其再次添加到项目中为我完成了工作!您可能需要清理项目。
回答by GrandSteph
I found the solution to be a missing file.
我发现解决方案是丢失的文件。
Original content:
原文内容:
For all the n00bs out there like me ... The image has to be PNG ...
对于所有像我这样的 n00bs ......图像必须是 PNG ...
回答by Leonardo Murri
Delete the image (by using the Remove Reference option)
删除图像(通过使用删除参考选项)
Re-Add it and make sure that in the add to targets section your project name is selected. (usually it happens when only yourPojectTests is selected)
重新添加它并确保在添加到目标部分中选择了您的项目名称。(通常仅在选择 yourPojectTests 时发生)

