Загружаю содержимое в UITableView из WS, и я попытался загрузить изображения асинхронно. Каждый раз, когда я «перемещаю» таблицу, изображения снова загружаются.Кэширование изображений UITableView после загрузки асинхронно
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"NewsCell";
NewsCell *cell = ......
NewsObject *obj = [self.dataSourceArray objectAtIndex:indexPath.row];
cell.labelTitle.text = obj.title;
cell.textViewNews.text = obj.summary;
cell.imgListIcon.image = nil;
dispatch_queue_t imageQ = dispatch_queue_create("imageQ", NULL);
dispatch_async(imageQ, ^{
NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:obj.img]];
dispatch_async(dispatch_get_main_queue(), ^{
cell.imgListIcon.image = [UIImage imageWithData:imageData];
[cell setNeedsLayout];
[cell.spinner stopAnimating];
});
});
dispatch_release(imageQ);
return cell;
}
Может кто-нибудь помочь мне с некоторыми советами по поводу этой проблемы? Спасибо!