【发布时间】:2016-08-01 17:06:48
【问题描述】:
从我的网络服务中,我得到了多个尺寸的图像。我正在将它们加载到 TableView 中。当我加载它们时,尚未缓存的新图像在占位符和原始图像之间闪烁,或者有时图像看起来比通常的尺寸小。但是向下或向上滚动一点实际上可以解决问题,但我希望它们从一开始就保持原始大小。但我想下次它会以原来的形状出现,因为图片已经被缓存了
最初
稍微滚动一下
我在 cellForRowAtIndexPath 中的代码:
[cell.image sd_setImageWithURL:[NSURL URLWithString:[NSMutableString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath]]
placeholderImage:[UIImage imageNamed: @"image_loader.gif"]];
然后在 heightForRowAtIndexPath:
NSURL *filePath = [NSURL URLWithString:[NSMutableString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath]];
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:filePath];
UIImage *image = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key];
self.img = image;
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+140;
} else {
return self.img.size.height+180;
}
我访问过https://github.com/rs/SDWebImage,在他们的常见问题部分中他们提到了这个问题,但建议的解决方案对我不起作用!!!
【问题讨论】:
-
单元格中的imageview大小是否固定?
-
没有图像视图大小是根据图像大小动态变化的
标签: ios image caching sdwebimage