【发布时间】:2013-01-21 00:50:41
【问题描述】:
我正在尝试在 tableViewCell 上使用 AFNetworking 的 setImageWithURLRequest 在 ImageView 上设置图像。如果我在方法中不包含 success 和 failure 块,如下所示:
[cell.thumbnailImageView setImageWithURL:url placeholderImage:nil];
一切正常,图像设置。不幸的是我需要积木。
这是我目前在cellForRowAtIndexPath 中拥有的内容:
if (self.images) { //check if the array of images is set, fetched from a URL
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: [[self.images objectAtIndex:indexPath.row] objectForKey:@"tbUrl"]]];
[cell.thumbnailImageView setImageWithURLRequest:request placeholderImage:[UIImage imageNamed:@"placeholder"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSLog(@"success"); //it always lands here! But nothing happens
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"fail");
}];
}
【问题讨论】:
标签: iphone ios afnetworking block