xcode “UIImageView”没有可见的@interface 声明了选择器“setImageWithURL”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26888280/
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
No visible @interface for 'UIImageView' declares the selector 'setImageWithURL'
提问by Lock_85_Dr
Good afternoon,
下午好,
I'm trying to use SDWebImagein my TableViewController and I get an error two errors (one for each image element) but I can run the App and I can see that the SDWebImage is working fine, but with those 2 errors.
我试图在我的 TableViewController 中使用SDWebImage并且我收到一个错误两个错误(每个图像元素一个)但是我可以运行应用程序并且我可以看到 SDWebImage 工作正常,但是有这两个错误。
How is that possible? I'm really happy that SDWebImage worked, but I don't know it's showing those errors and then it's working.
这怎么可能?我真的很高兴 SDWebImage 工作正常,但我不知道它是否显示了这些错误,然后它正在工作。
Also I want to say that when I use "setImageWithURL" is working with those 2 errors (but that function is not linked) but when I use "sd_setImageWithURL" is not working and I also have those 2 errors (but the sd_setImageWithURL is linked to the SDWebImage files).
另外我想说的是,当我使用“ setImageWithURL”时,正在处理这两个错误(但该函数未链接)但是当我使用“ sd_setImageWithURL”时,我也有这两个错误(但 sd_setImageWithURL 链接到SDWebImage 文件)。
So, which one I have to use? Because I want this to make it work but I want to make it work OK without any errors.
那么,我必须使用哪一种?因为我想让它工作,但我想让它工作正常而没有任何错误。
I get the following error:
我收到以下错误:
No visible @interface for 'UIImageView' declares the selector 'setImageWithURL:placeholderImage:options:'
'UIImageView' 没有可见的 @interface 声明了选择器 'setImageWithURL:placeholderImage:options:'
Find below some code:
在下面找到一些代码:
CarTableViewController.m
CarTableViewController.m
#import "CarTableViewController.h"
#import "CarTableViewCell.h"
#import "CarTableViewController.h"
#import "CarDetailViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"carTableCell";
CarTableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CarTableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.makeLabel.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"id"];
cell.likes.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"likes"];
cell.comments.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"comments"];
cell.username.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"username"];
cell.refuser.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"user_ref"];
cell.modelLabel.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"user"];
NSURL * imageURL = [NSURL URLWithString:[[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"imagen"]];
[cell.carImage setImageWithURL:imageURL
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
options:SDWebImageRefreshCached];
NSURL * imageURL2 = [NSURL URLWithString:[[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"image"]];
[cell.profileImage setImageWithURL:imageURL2
placeholderImage:[UIImage imageNamed:@"image"]
options:SDWebImageRefreshCached];
return cell;
}
And that's my CarTableViewCell.h:
这就是我的CarTableViewCell.h:
#import <UIKit/UIKit.h>
@interface CarTableViewCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UIImageView *carImage;
@property (nonatomic, strong) IBOutlet UILabel *makeLabel;
@property (nonatomic, strong) IBOutlet UILabel *modelLabel;
@property (nonatomic, strong) IBOutlet UILabel *likes;
@property (nonatomic, strong) IBOutlet UILabel *comments;
@property (nonatomic, strong) IBOutlet UILabel *username;
@property (nonatomic, strong) IBOutlet UILabel *refuser;
@property (nonatomic, strong) IBOutlet UIImageView *profileImage;
@end
Thanks in advance.
提前致谢。
回答by l0gg3r
You need to call
你需要打电话
[cell.carImage sd_setImageWithURL:imageURL
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
options:SDWebImageRefreshCached];