2017-10-12 71 views
1

如何檢索正確的圖像時使用翠鳥圖像url沒有改變,但圖像改變,如Twitter或GitHub。如何設置圖像使用翠鳥時,圖像url沒有改變,但圖像更改

SDWebImage有一個選項[SDWebImageRefreshCached]來解決問題。

/** 
    * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. 
    * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. 
    * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. 
    * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. 
    * 
    * Use this flag only if you can't make your URLs static with embedded cache busting parameter. 
    */ 
    SDWebImageRefreshCached = 1 << 4, 

如何解決翠鳥問題?

回答

1

Kingfisher有forceRefresh選項強制下載的圖像再次skiping緩存

imageView.kf.setImage(with: url, options: [.forceRefresh]) 

請參閱本github線程的詳細信息