下午好,
我正在尝试在我的TableViewController中使用 SDWebImage ,但是我遇到了两个错误(每个图像元素一个错误),但我可以运行应用程序并且可以看到 SDWebImage 正常工作,但是伴随着这两个错误。
这怎么可能?我真的很高兴 SDWebImage 工作了,但我不知道它为什么会显示这些错误然后又工作了。
此外,当我使用“setImageWithURL”时,那两个错误也出现了(但未链接该函数),但当我使用“sd_setImageWithURL”时则不起作用,并且我还有那两个错误(但 sd_setImageWithURL 链接到 SDWebImage 文件)。
那么,我应该使用哪一个?因为我想让它正常工作,但又不想有任何错误。
我收到以下错误:
'UIImageView'没有声明选择器“setImageWithURL:placeholderImage:options:”
以下是一些代码:
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;
}
这是我的 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
提前致谢。
sd_
前缀,现在应该可以正常工作了。 - l0gg3r