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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31198946/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 06:42:17  来源:igfitidea点击:

Could not load the "" image referenced from a nib in the bundle with identifier

iosiphone

提问by Hilaj

when I load my application it shows a warning message that

当我加载我的应用程序时,它会显示一条警告消息

"Could not load the "" image referenced from a nib in the bundle with identifier "

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

I searched and confirmed all my images. But it still shows that warning.

我搜索并确认了我所有的图像。但它仍然显示该警告。

采纳答案by Chase Roberts

  1. Select your image(s) in Project Navigator.
  2. Open the File Inspector.
  3. Make sure you have the target selected.
  1. 在项目导航器中选择您的图像。
  2. 打开文件检查器。
  3. 确保您选择了目标。

Add your image to the target

将您的图像添加到目标

回答by Tal Zion

I had the same issue when I Refactor to Storyboard. Apparently the Asset catalog does not transfer the image reference. To fix, see below:

我有同样的问题Refactor to Storyboard。显然资产目录不传输图像参考。要修复,请参见下文:

You would notice that your ImageViewsis empty from reference.

你会注意到你的ImageViews引用是空的。

Image Views

图像浏览量

1 - Click on the ImageView

1 - 单击 ImageView

Click the Image View

单击图像视图

2 Go to the Utilities bar where you would see you asset image is unknown

2 转到实用工具栏,您将在其中看到资产图像 unknown

Unknow Image

未知图像

3 - Change it back to you image asset

3 - 将其改回您的图像资产

Choose your image again

再次选择您的图像

This should fix your error. Hope this helps!

这应该可以解决您的错误。希望这可以帮助!

回答by Kumar

There might be many reasons of this error. To fix this issue you can just follow below given step:

这个错误可能有很多原因。要解决此问题,您可以按照以下给定步骤操作:

  1. Go to product menu of the Xcode, select clean.
  2. If still you are getting the error, then remove the images from your project and again add the images to your project.
  3. while adding image into the project, make sure that you have selected the Project name inside the "Add to targets". And also enable the "Copy items if needed".
  1. 转到 Xcode 的产品菜单,选择clean
  2. 如果仍然出现错误,请从项目中删除图像,然后再次将图像添加到项目中。
  3. 在将图像添加到项目中时,请确保您在“添加到目标”中选择了项目名称。并启用“如果需要,复制项目”。

Please Refer below image for better understanding:

请参考下图以便更好地理解:

First Image convey that while uploading image the TestTests is enable under **Add to targets**

第一张图片表明,在上传图片时,TestTests 在 **Add to targets** 下启用

Due to the above process we are getting error, as we can see in the console of Xcode

由于上述过程,我们得到了错误,正如我们在 Xcode 的控制台中看到的那样

Image 3rd show the correct way of uploading image/file into the project

图 3 显示了将图像/文件上传到项目中的正确方法

The final image 4th show the output without any error/warning

The final image 4th show the output without any error/warning

回答by Bhanupriya

Just select the image in Xcode and in right side, File inspector, under 'Target Membership' make sure your project is selected. Another thing you can do is delete and re insert your image and make sure 'Copy items if needed' is selected and 'Add to targets' your project is selected.

只需在 Xcode 中选择图像,然后在右侧的文件检查器中,在“目标成员资格”下确保选择了您的项目。您可以做的另一件事是删除并重新插入您的图像,并确保选择“需要时复制项目”并选择“添加到目标”您的项目。

回答by naughtynaj

  1. Click on the image file in your Xcode navigator.
  2. Once selected, go to the right side bar (of XCODE) which is utilities and under file inspector, scroll to target membership and select your project target file.
  3. Then build and run the project again.
  1. 单击 Xcode 导航器中的图像文件。
  2. 选择后,转到实用程序和文件检查器下的右侧栏(XCODE),滚动到目标成员并选择您的项目目标文件。
  3. 然后再次构建并运行项目。

回答by hstdt

Xcode9 beta2 release note:

Xcode9 beta2 发行说明:

Jpeg assets in asset catalogs are not found on iOS 10 or earlier for apps built with Xcode 9. APIcalls for accessing the image such as UIImage.imageNamed: return nil. (32524123)

Workaround: Use png resources or limit app testing to devices running iOS 11 or later.

对于使用 Xcode 9 构建的应用程序,在 iOS 10 或更早版本上找不到资产目录中的 Jpeg 资产。用于访问图像的 APIcalls,例如 UIImage.imageNamed: return nil。(32524123)

解决方法:使用 png 资源或将应用测试限制为运行 iOS 11 或更高版本的设备。

Xcode9 beta3 release note:

Xcode9 beta3 发行说明:

Jpeg assets in asset catalogs are found on iOS 10 or earlier for apps built with Xcode 9.(32524123)

对于使用 Xcode 9 构建的应用程序,可以在 iOS 10 或更早版本上找到资产目录中的 Jpeg 资产。(32524123)

回答by agy

You can try opening your storyboard or nib as Source Code and then "Find" the image name in it, see if it exists but already invalid in your project, probably you have deleted or changed its name, and now it doesn't seem valid.

您可以尝试打开您的故事板或笔尖作为源代码,然后在其中“查找”图像名称,查看它是否存在但在您的项目中已经无效,可能您已经删除或更改了它的名称,现在它似乎无效.

回答by M. Houghton

I have just updated to XCode 9 and it started giving me this issue. I created a new Image Set in the Assets section and added the images I wanted to this, then re-added them to my tab bar images with custom names and it worked fine. Hope this helps!

我刚刚更新到 XCode 9,它开始给我这个问题。我在 Assets 部分创建了一个新的 Image Set 并添加了我想要的图像,然后使用自定义名称将它们重新添加到我的标签栏图像中,并且效果很好。希望这可以帮助!

回答by raf

PROBLEM
This happened to me seemingly out of the blue on a tab bar controller with icons for each tab. The storyboard was still showing my image icons and the assets existed with the expected names.

问题
在带有每个选项卡图标的选项卡栏控制器上,这似乎突然发生在我身上。故事板仍然显示我的图像图标,并且资产以预期的名称存在。

MY FIX
Select the tab bar icons in their respective view controller and reassign the image like you did the first time.

我的修复
在各自的视图控制器中选择标签栏图标并像第一次一样重新分配图像。

回答by SalokinSwift

This happened to me as well. I was doing everything right when adding the image but for some reason it was not working. I had to click on the image again once added, and then on the right toolbar under "Target Membership" I noticed my project was not selected even though I was selecting it when adding the image. I selected it here and everything worked fine.

这也发生在我身上。添加图像时我做的一切都是正确的,但由于某种原因它不起作用。添加后我不得不再次单击图像,然后在“目标成员资格”下的右侧工具栏上,我注意到我的项目没有被选中,即使我在添加图像时选择了它。我在这里选择了它,一切正常。