无法加载从带有标识符的包中的笔尖引用的图像

发布于 2024-10-08 05:32:48 字数 495 浏览 1 评论 0原文

我有一个 iPad 应用程序。ViewContrtoller.xib 中有一个 UIImageViewUIImageViewUIImage 是通过 Interface Builder 设置的。当我在模拟器中运行应用程序时,一切都很好。但是当我尝试在 iPad 中运行它时,UIImage 未加载。我收到的消息是:

HexaPuzzle1.0[3259:207] 无法加载从标识符为“com.yourcompany.HexaPuzzle1-0”的包中的笔尖引用的“start.png”图像 2010-12-17 10:57:27.221 HexaPuzzle1.0[3259:207] HexaPuzzle 已加载

任何帮助将不胜感激,并将对我有很大帮助。

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:

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

Any help would be appreciated and will be a great help for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

番薯 2024-10-15 05:32:49

该问题已得到纠正。
问题出在图像格式上。当图像被编辑并保存为 PNG-24 时,一切都会正常。
该应用程序现在可以在模拟器和设备中顺利运行。

感谢所有提出解决方案并试图帮助我的朋友。

问候,
鲁佩什·R·梅农

The issue has been rectified.
Problem was with the image format. When the image has been edited and saved as PNG-24 everything goes fine.
The application now runs smoothly in simulator and device.

Thanks for all friends who suggested a solution and tried to helped me.

Regards,
Rupesh R Menon

像你 2024-10-15 05:32:49

我知道已经很晚了,但这是一个也适用于 Xcode 5 的解决方案,因此可能对将来遇到此问题的人有用。

我在网上看到过很多这样的问题,但似乎没有一个有明确的答案。据我所知,这是这个问题的解决方案:

  • 转到Xcode中的图像(无需重新添加或重新生成
    图片)
  • 单击“显示文件检查器”
  • 确保选中“目标成员资格”类别中的复选框。不必选中测试复选框即可使您的应用程序加载图像。

目标会员选项卡如下所示:

在此处输入图像描述

如果已经是这种情况,您正在处理损坏的文件。要排除这种情况,请检查其他应用程序(例如 Photoshop)是否可以打开您的图像。

应该可以做到这一点,希望有帮助!

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.

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.

The target membership tab looks like this:

enter image description here

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.

This should do it, hope it helps!

冷清清 2024-10-15 05:32:49

start.png 文件拖到项目中时,您是否选中了此选项?

替代文本

When dragging your start.png file into your project, did you check this option?

alt text

彩虹直至黑白 2024-10-15 05:32:49

升级到 Xcode 7 / iOS 9 并打开现有项目后,我在模拟器中收到此错误。该图像在 XCAssets 包中存在且命名正确。

结果发现问题出在 XCAssets 包中的一个参数上。

渲染为默认更改为原始图像解决了问题:

在此处输入图像描述

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.

Turns out the problem was with a parameter within the XCAssets package.

Changing Render As from Default to Original Image solved the problem:

enter image description here

九局 2024-10-15 05:32:49

我以前也遇到过同样的问题。 png 文件格式不正确。尝试重新生成png图像文件,问题即可解决。

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.

緦唸λ蓇 2024-10-15 05:32:49

以上都不适合我,我收到的消息是“无法加载引用的“(空)”图像...这意味着我无法查找该图像。非常令人沮丧。最终它变成了一次试验,并且通过检查每个 xib 和故事板寻找潜在冲突的错误练习,我终于找到了它 - 我为不需要的选项卡栏项目指定了“选定的图像”。

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.

独守阴晴ぅ圆缺 2024-10-15 05:32:49

这些东西都不适合我。我在放置图片的项目中创建了一个新文件夹。这对我有用。

None of these things work for me. I created a new folder in the projects where I placed the pictures. That worked for me.

囚我心虐我身 2024-10-15 05:32:49

当我将图像导入到项目中时,将“添加文件夹引用...”更改为“添加组...”时,此问题得到了解决。我更喜欢具有实时更新功能的文件夹,但至少现在可以使用。

This problem was fixed when I changed "add folder reference..." to "add group..." when I import the images to my project. I'd prefer to have folders with live updating, but at least it works now.

熊抱啵儿 2024-10-15 05:32:49

在 XIB 上有一张图像(在代码中被正确的图像替换)。完成此 XIB 后,我重命名了图像。所以 XIB 现在引用了一个不存在的图像。

Had an image on a XIB (which is replaced by the correct one in code). After finishing this XIB, I renamed the images. So XIB was now referencing a non-existent image.

雪落纷纷 2024-10-15 05:32:49

此问题还有另一个潜在原因:如果您升级到 XCode 5 并使用图像资源目录和复制到项目中的“普通”图像(就像之前的 XCode 5 一样)。如果您有具有相同名称的图像(例如“dog.png”和名为“dog”的图像集),它可能会在故事板和模拟器中工作,但在真实设备上运行时您会收到此消息(其中图像将不会显示)。

There is also another potential cause of this problem: If you upgraded to XCode 5 and use both the image asset catalog and "normal" images copied to your project (like you did prior XCode 5). If you then have images with identical names (e.g. "dog.png" and a image set called "dog") it might work in your storyboard and in the simulator, but you'll get this message when run on a real device (where the image will not be shown).

羁拥 2024-10-15 05:32:49

尝试将图像直接移动到资源目录(而不是子文件夹中)

Try moving the images directly to the Resources directory (not in a sub folder)

简美 2024-10-15 05:32:49

确保资源不会太大而无法处理。

Make sure the resource isn't too big to be handle.

柠檬色的秋千 2024-10-15 05:32:49

如果您收到带有图片名称的错误消息,您可以在项目中搜索它,xCode 将立即在 UIStoryboard 中显示带有错误图片的 UIImageView:

在此处输入图像描述

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:

enter image description here

强辩 2024-10-15 05:32:49

确保它包含在您的目标会员资格中

  1. 在文件检查器中选择您的“Images.xcassets”文件
  2. 打开文件检查器 (cmd + opt + 1)
  3. 选择您的目标会员资格(通常是第一行)

Make sure it is included in your Target Membership

  1. Select your "Images.xcassets" file in the file Inspector
  2. Open File Inspector (cmd + opt + 1)
  3. Select your target membership (Usually 1st line)
夜清冷一曲。 2024-10-15 05:32:49

我也遇到了同样的问题,但原因却截然不同。我在资产目录中使用的图像集根据设备习惯而变化:iPad 或 iPhone。

它们被添加到的框架目标被意外标记为具有 iPhone 部署设备类型,因此图像没有显示在 iPad 上 - 它们甚至没有被复制到 <框架中的 code>.car 文件。

将部署设备类型设置为“通用”(应该如此)可以解决问题。

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.

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.

Setting the deployment device type to Universal, as it should have been, solved the problem.

枕头说它不想醒 2024-10-15 05:32:49

由于某种原因,我收到错误,直到将图像放入 Assets.xcassets 中

For some reason I was getting error until I put the image in the Assets.xcassets

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文