ios 无法加载从带有标识符的包中的笔尖引用的图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4468053/
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
Could not load the image referenced from a nib in the bundle with identifier
提问by Rupesh R Menon
I had got an iPad
application.The ViewContrtoller.xib
has got an UIImageView
in it. The UIImage
of the UIImageView
is set through Interface Builder
. When I run the application in simulator everything is fine. But when I am trying to run it in iPad
the UIImage
is not loaded. The message that I am getting is:
我有一个iPad
应用程序。其中ViewContrtoller.xib
有一个UIImageView
。该UIImage
的UIImageView
设置通过Interface Builder
。当我在模拟器中运行应用程序时,一切都很好。但是,当我试图运行中iPad
的UIImage
不加载。我收到的消息是:
HexaPuzzle1.0[3259:207] Could not load the "start.png" image referenced from a nib in the bundle with identifier "com.yourcompany.HexaPuzzle1-0" 2010-12-17 10:57:27.221 HexaPuzzle1.0[3259:207] HexaPuzzle loaded
HexaPuzzle1.0[3259:207] 无法加载从标识符为“com.yourcompany.HexaPuzzle1-0”的包中的笔尖引用的“start.png”图像 2010-12-17 10:57:27.221 HexaPuzzle1.0[ 3259:207] HexaPuzzle 已加载
Any help would be appreciated and will be a great help for me.
任何帮助将不胜感激,对我来说将是一个很大的帮助。
回答by Rupesh R Menon
The issue has been rectified. Problem was with the image format. When the image has been edited and saved as PNG-24everything goes fine. The application now runs smoothly in simulator and device.
该问题已得到纠正。问题在于图像格式。当图像被编辑并保存为PNG-24 时,一切正常。该应用程序现在可以在模拟器和设备中顺利运行。
Thanks for all friends who suggested a solution and tried to helped me.
感谢所有提出解决方案并试图帮助我的朋友。
Regards, Rupesh R Menon
问候, Rupesh R Menon
回答by Joris416
I know it's very late, but this is a solution that also works in Xcode 5, and therefore likely to be useful to people who have this problem in the future.
我知道现在已经很晚了,但这是一个也适用于 Xcode 5 的解决方案,因此可能对将来遇到此问题的人有用。
I have seen a lot of questions like this on the web but none of them seems to have one clear answer. This is, as far as I know, the solution for this problem:
我在网上看到很多这样的问题,但似乎没有一个有明确的答案。据我所知,这是这个问题的解决方案:
- Go to the image in Xcode (no need to re-add or re-generate the image)
- click "show the file inspector"
- Make sure the checkbox in the category "Target Membership" is checked. the test check box does not have to be checked to make your app load the image.
- 在 Xcode 中转到图像(无需重新添加或重新生成图像)
- 单击“显示文件检查器”
- 确保选中“目标会员”类别中的复选框。不必选中测试复选框即可让您的应用加载图像。
The target membership tab looks like this:
目标成员资格选项卡如下所示:
if this is already the case, you are working with a broken or damaged file. to rule this out, check if another app (like photoshop) can open your image.
如果已经是这种情况,则您正在处理损坏或损坏的文件。要排除这种情况,请检查其他应用程序(如 photoshop)是否可以打开您的图像。
This should do it, hope it helps!
这个应该可以了,希望有帮助!
回答by Di Wu
When dragging your start.pngfile into your project, did you check this option?
将start.png文件拖入项目时,是否选中了此选项?
回答by jt_uk
I was getting this error in the simulator after upgrading to Xcode 7 / iOS 9 and opening an existing project. The image was present and named correctly, within an XCAssets package.
升级到 Xcode 7 / iOS 9 并打开现有项目后,我在模拟器中收到此错误。该图像在 XCAssets 包中存在并正确命名。
Turns out the problem was with a parameter within the XCAssets package.
原来问题出在 XCAssets 包中的一个参数上。
Changing Render As
from Defaultto Original Imagesolved the problem:
Render As
从默认更改为原始图像解决了问题:
回答by Kam
I've had the same problem before. The png file format is not right. Try re-generate the png image file and the problem will be solved.
我以前也遇到过同样的问题。png 文件格式不对。尝试重新生成png图片文件,问题就解决了。
回答by Darren
None of the above worked for me, and the message I got was "could not load the "(null)" image referenced... which means I could not look for the image. Very frustrating. In the end it became a trial and error exercise of going through every xib and storyboard looking for potential conflicts. I finally found it - I had specified a "Selected Image" for a tab bar item which was not needed. As soon as I got rid of that the problem went away.
以上都不适合我,我得到的消息是“无法加载引用的“(空)”图像......这意味着我无法寻找图像。非常令人沮丧。最终它变成了一个试验和通过每个xib和故事板寻找潜在冲突的错误练习。我终于找到了 - 我已经为不需要的标签栏项目指定了“选定图像”。一旦我摆脱了这个问题,问题就消失了。
回答by eslamb
Make sure the resource isn't too big to be handle.
确保资源不会太大而无法处理。
回答by Alex Cio
If you get the error message with the name of the picture, you can search it inside your project and xCode
will display immediately the UIImageView
with the wrong picture inside UIStoryboard
:
如果您收到带有图片名称的错误消息,您可以在您的项目中搜索它,并xCode
立即显示UIImageView
里面包含错误图片的信息UIStoryboard
:
回答by KIO
Make sure it is included in your Target Membership
确保它包含在您的目标会员资格中
- Select your "Images.xcassets" file in the file Inspector
- Open File Inspector (cmd + opt + 1)
- Select your target membership (Usually 1st line)
- 在文件检查器中选择您的“Images.xcassets”文件
- 打开文件检查器(cmd + opt + 1)
- 选择您的目标会员(通常是第一行)
回答by Dafydd Williams
I had the same problem, but the cause was very different. I was using image sets in the Asset Catalog that varied based on the device idiom: iPad or iPhone.
我遇到了同样的问题,但原因却大不相同。我使用的是资产目录中的图像集,这些图像集因设备习惯用法而异:iPad 或 iPhone。
The framework target they were being added to had been accidentally marked as as having a deployment device type of iPhone
, so the images weren't showing up on iPads - they weren't even being copied into the .car
file in the framework.
他们被添加到的框架目标被意外标记为部署设备类型为iPhone
,因此图像没有显示在 iPad 上 - 它们甚至没有被复制到.car
框架中的文件中。
Setting the deployment device type to Universal
, as it should have been, solved the problem.
将部署设备类型设置为Universal
,正如它应该的那样,解决了问题。