UIImageView | unrecognized selector sent to instan

2020-03-30 05:50发布

问题:

I'm new at Xcode, and my task was to migrate the code from iOS 6.1 to 8.4, but there where so many deprecated methods. I solved them (I hope so), but now I got a new problem.

The code I'm using is this one:

[self.clientImageView sd_setImageWithURL:[NSURL URLWithString:_client.imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; 

And I get this error:

[UIImageView sd_setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x7fbe937a88b0

And finally, I get this:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView sd_setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x7fbe937a88b0'

Thank you so much.

回答1:

By the Collaborator ofSDWebImage

See https://github.com/rs/SDWebImage#add-linker-flag. Correctly setting the flags should take care of the issue. BTW: I strongly recommend you guys switch to CocoaPods, that way those issues will never arise.



回答2:

If you imported the framework and set up all of the right flags, try to delete the contents of this folder ~/Library/Developer/Xcode/DerivedData and fun a clean build. It should help.



回答3:

Just add -ObjC in other linker flags and added sdwebcache.a in link libraries



回答4:

Copy and paste all files from the library in your project. I tried everything suggested and nothing worked. At the end, simple copy paste do the work.

Also, I must say that I didn't have this problem on the new project, just in existing one. On the new project everything worked just fine.