Could not load the “” image referenced from a nib

房东的猫 提交于 2019-12-17 22:11:44

问题


I have no images called "" (nothing). I've gone through the .xib file of the screen where this pops up and can't find anything that would cause this. Anybody who have had the same issue? Here is the full warning:

Could not load the "" image referenced from a nib in the bundle with identifier "com.blah.Blah"


回答1:


You can do this to check it from your storyboard, or nib. Open it as Source Code:

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.




回答2:


I had the same issue and in my case there was an UIButton with an invalid image reference in the storyboard file. The reference wasn't empty so it was not trivial to spot by just searching for "" in the storyboard file. However, Xcode did show "Unknown image" for the button in the Background field instead of "Default Background Image". In the storyboard file it appeared as

<state key="normal" title="Use" backgroundImage="0E39AEA8-7F29-40B2-96B1-63B99047E8D5">

so perhaps grepping for backgroundImage and looking for non-familiar references will help find the cause.




回答3:


I had this warning because of a UITabBarItem. In the attributes inspector for the field "Selected Image" I had a file listed that was also the value for the field "Image". Nevertheless, I received warnings until I made the "Selected Image" field blank.




回答4:


Just for reference, this problem is also caused by using .jpg images and referencing them inside of storyboards/nibs. iOS 8 appears to be able to handle the proper type checking between jpg and png images at runtime. However, on iOS 7 and below you will need to manually set the image in the code and remove the image reference inside of the storyboard to get rid of the warning.

Remember you need to manually set the .jpg when referencing jpg images.

[self.imageView setImage:[UIImage imageNamed:@"yourImage.jpg"]];



回答5:


I came looking for the answer. I searched my entire project and storyboard source code for "" and nowhere could I find it. The clue that the view that is displayed when the error appears is the one you need.

  • Open your xib or storyboard selecting the relevant viewController.

  • On the left click all grey arrows to expand the selection in your view

  • look for the UIImageView icon (its the one with the palm tree)

  • select it and open the "Attributes inspector" on the right hand side.

  • In the ImageView section at the top in either or both Image and
    Highlighted you will see greyed out "unknown image".

  • Use the drop down menu to change this from "unknown image" and build run

  • voila




回答6:


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". 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.




回答7:


In my case it was Unknown image in UIBarButtonItem in storyboard.




回答8:


Very simple remove the image that is not displaying from you project and then clean the project by going to Product--> clean then once again put the image into your project and done. this worked for me.




回答9:


In xcode 5.1 I had this same issue. The only way I could finally get it to work when using storyboard was to add the images as an image asset catalog. From what I read maybe they changed something in 5.1. I thought that storyboards don't have nibs - so it would make sense that asset catalog replaces the old method.

Project > General > App Icon Arrow > Import New Folder.

As soon as I did that the NIB references went away and my images showed up.




回答10:


I'm using Asset Catalog on Xcode 6. Simply removing and re-adding the Asset Catalog fix the problem




回答11:


in my situation, in my xib file,I had ever setup image name for some UIButton and UIImageView ,and delete these image name after sometime, but for unknown reason, these image still apear in the Interface Builder Editer, finally I reset these image name with any image name and delete them again,now problem resolved.




回答12:


This worked for me:

1- Quit Xcode

2- Make a copy of your .storyboard for backup.

3- Open your .storyboard in a text editor and delete image nodes and image node attributes with empty references.

delete node like this --> <image name=" " .../>
delete image attributes like this --> <tabBarItem key="tabBarItem" title="untitled" image=" " id="6"/>

4- Save the file
5- Open your project again in Xcode.
6- Run Product->Clean
7- Run your project

Warning should be gone.




回答13:


I had a very similiar problem which I eventually found. The line below was causing the problem using the open as source code method mentioned above.

<tabBarItem key="tabBarItem" title="Events" 
            image="319365D1-7058-46CD-8420-18E0EAFB2F29" id="a5a-IF-j9f"/>



回答14:


I got this error from an undo action, simply dropping the image back onto the view controller solved the problem.

Atb




回答15:


In my case it was because one of my button images was wrongly added to the Background Image container instead of the Image container (in the Inspector). I found it by going through the entire storyboard hierarchy and checking each image and button setting.




回答16:


Please do a search for image= shows various results. Select results from nibs or storyboard open it, if there is some value like image="2342D4DF-1E6B-42B8-847A-F9F622921D02" delete it and enjoy.




回答17:


i also faced same problem because i edited image in photoshop and saved as a psd format make sure you save your edited images in jpg or png format in my case that was the problem hope it helps!!!




回答18:


I got this problem for all of my images after switching one of the label's text to 'attributed' and using one of the 'Fun' fonts. Even though I switch it back to 'plain' I still get the "Could not load..." error - until I re-load and re-reference all of my images again.




回答19:


Initially my image name is "bg" When i found issue, i rename image as "background" but when click on image and hit "Show in Finder"changes was not reflected. image was name as "bg-1.jpg".

so i removed from project convert image to png and drag and drop into project it works for me.




回答20:


Make sure the 'Target Memebership' for the 'Assets.xcassets' has been selected.

  1. Click 'Assets.xcassets'
  2. In the 'File inspector', make sure 'Target Membership' selected.


来源:https://stackoverflow.com/questions/12672603/could-not-load-the-image-referenced-from-a-nib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!