When I am trying to load image using SDWebImage,it's showing error like
< No visible @interface for 'UIImage' declares the selector 'sd_setImageWithURL:placeholderImage:'>
I am trying to load the image in a imageview in tableview cell like this:
[newsImage.image sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row] objectForKey:@"image"]]
placeholderImage:[UIImage imageNamed:@"tab.png"]];
Change
[newsImage.image sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row] objectForKey:@"image"]]
placeholderImage:[UIImage imageNamed:@"tab.png"]];
To
[newsImage sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row] objectForKey:@"image"]]
placeholderImage:[UIImage imageNamed:@"tab.png"]];
If newsImage
is your UIImageView
then code should be as below.
[newsImage sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row] objectForKey:@"image"]]
placeholderImage:[UIImage imageNamed:@"tab.png"]];
-(void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
Above method is for UIImageView
and you were applying this method to UIimage
so it might crashing.
Apply this method on imageView , and not on imageView.image
Use this code :
[newsImage sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row] objectForKey:@"image"]] placeholderImage:[UIImage imageNamed:@"tab.png"]];
Also don't forget to import
#import <SDWebImage/UIImageView+WebCache.h>
Please try with below code -
Add in your viewcontroler - #import <SDWebImage/UIImageView+WebCache.h>
[newsImage sd_setImageWithURL:[NSURL URLWithString:[jsonResult[indexPath.row]
placeholderImage:[UIImage imageNamed:@"tab.png"]
options:SDWebImageRefreshCached];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.