SDWeb图像是否自动缓存下载的图像?

时间:2017-05-20 14:19:44

标签: ios image caching swift3 sdwebimage

我有一个简单的集合视图,其中有一个从URl下载的图像

我尝试使用SD Web图像而不是缓存这些图像

这是我的代码

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "carOwnerCell", for: indexPath) as! CarOwnerCollectionViewCell

      cell.requestImage.sd_setShowActivityIndicatorView(true)
      cell.requestImage.sd_setImage(with: URL(string: "My url "))

      return cell 

    }

图像已下载,但每次我在集合中滚动时都会继续下载图像。如何使用SD网页图像缓存下载图像

1 个答案:

答案 0 :(得分:0)

首先你应该检查(“我的网址”)是图像的正确URL,然后给出占位符图像,如果它显示占位符图像意味着工作正常