ウェブURLからUITableViewCell
に画像をロードしています。これらの画像のサイズは画像あたり約80〜100kbです。私は非同期的に画像をダウンロードするとすべてうまく動作します。but when i scroll the tableview, images start again downloading. Can i get rid of this
私は行の数が制限されているので。 URLダウンロードの画像をもう一度ダウンロードしてはならない場合は、画像のダウンロードが再開されたときにユーザーが快適に閲覧できないようにします。iOS UITableViewCell URLからの画像
私はCellforRowAtIndexPath
で画像をロードするためのコードの下に使用しています:
dispatch_async(dispatch_get_global_queue(0,0), ^{
NSData * data = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:url];
if (data == nil)
return;
dispatch_async(dispatch_get_main_queue(), ^{
cell.eventImage.image= [UIImage imageWithData:data];
});
});
SDWebImageを使用してイメージをキャッシュし、最初にdownload.https://github.com/rs/SDWebImage –