【发布时间】:2014-03-21 15:04:11
【问题描述】:
我正在使用 AFNetworking 下载设置为表格视图的 rss 提要图像。以下是我正在使用的代码。
- (UITableViewCell *)tableView:(UITableview *)tableView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
NSString *wallpaperLink = [af setThumbString:[[feeds objectAtIndex:indexPath.row] objectForKey: @"wallpaper"]];
//AfNetwork Download
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:wallpaperLink]]];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
//Set Cell Image from response
cell.imageView.image = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
return cell;
}
但是当我阅读一些教程时,我意识到这不是使用 AFNetworking 下载异步图像的方法。谁能告诉我我的代码,如何下载和添加responseobject 到cell.imageView.image ???
【问题讨论】:
标签: ios objective-c uitableview afnetworking