使用第三方框架进行异步图像下载时性能变慢。我试过AFNetworking
and SDWebImage
,滚动UICollectionView
变得很慢。
我尝试了以下方法:
-(void)setImageForIndexPath:(NSIndexPath*)path withUrl:(NSURL*)url{
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFImageRequestOperation *operation;
operation = [AFImageRequestOperation imageRequestOperationWithRequest:request success:^(UIImage *image) {
CollectionCellPreview *cell = (CollectionCellPreview *)[self.collectionView cellForItemAtIndexPath:path];
cell.myImageView.image = image;
}];
[operation start];
}
同样:
[cell.imageLocation setImageWithURL:url];
使用这个框架我是否遗漏了一些重要的东西?它看起来非常有用和强大,我不明白为什么它会这样。