SDWebImage加載圖片時(shí)是有緩存的,緩存時(shí)間為1周。使用- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;時(shí),首先查看緩存中是否有圖片,若有,則優(yōu)先加載緩存而不是直接下載;沒(méi)有的話再?gòu)暮笈_(tái)獲取。
加載圖片不改變時(shí),是因?yàn)閳D片的url是不變的,而默認(rèn)情況下,SDWebImage對(duì)相同url是優(yōu)先使用緩存的,因此得加options屬性。(可以卸載APP后重新下載)
[xxxxx sd_setImageWithURL:[NSURL URLWithString:userDto.userImgUrl] placeholderImage:[UIImage imageNamed:@"xxxxx"] options:SDWebImageRefreshCached];
如果不能解決請(qǐng)?jiān)囉孟旅娣椒ǎ?/p>
UIImage *imagea = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:model.shop_logo]]];
cell.ImgView.image = images;
SDWebImageRefreshCached是專門(mén)用來(lái)處理相同url,圖片不同的情況的。
這兩種寫(xiě)法根據(jù)情況而定。