【发布时间】:2016-07-26 12:37:42
【问题描述】:
我正在使用SDWebImage 来缓存图像。但它不起作用。我在cellForRowAtIndexPath下以这种方式使用它:
[cell.image sd_setImageWithURL:[NSURL URLWithString:[NSMutableString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath]]
placeholderImage:[UIImage sd_animatedGIFNamed:@"image_loader.gif"] options:SDWebImageRefreshCached];
我想它是异步下载图像的。但是我的应用在滚动UITableView 时冻结。并且在向上滚动时也有网络使用,对我来说这不应该发生,因为我正在缓存它。
除了我有一些逻辑可以根据heightForRowAtIndexPath 下的图像大小调整UIImageView 框架的大小,这可能是什么原因???
if(data.type == 2)
{
height = 260.00;
}
else if(data.type == 1)
{
height = self.view.frame.size.width/2 + 115;
}
else
{
NSString *filePath = [NSString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath];
self.img = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:filePath]]];
if (self.img.size.width > CGRectGetWidth(self.view.bounds)) {
CGFloat ratio = self.img.size.height / self.img.size.width;
return CGRectGetWidth(self.view.bounds) * ratio+120;
} else {
return self.img.size.height+110;
}
}
【问题讨论】:
-
查看已编辑的答案@Fay007
标签: ios uitableview caching sdwebimage