SDWebImage加載圖片時是有緩存的,緩存時間為1周。使用- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;時,首先查看緩存中是否有圖片,若有,則優(yōu)先加載緩存而不是直接下載;沒有的話再從后臺獲取。
加載圖片不改變時,是因為圖片的url是不變的,而默認情況下,SDWebImage對相同url是優(yōu)先使用緩存的,因此得加options屬性。(可以卸載APP后重新下載)
[xxxxx sd_setImageWithURL:[NSURL URLWithString:userDto.userImgUrl] placeholderImage:[UIImage imageNamed:@"xxxxx"] options:SDWebImageRefreshCached];
如果不能解決請試用下面方法:
UIImage *imagea = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:model.shop_logo]]];
cell.ImgView.image = images;
SDWebImageRefreshCached是專門用來處理相同url,圖片不同的情況的。
這兩種寫法根據情況而定。