SDWebImage 라이브러리를 사용하여 컬렉션보기에서 이미지를로드하고 있습니다.SDWebImage 캐싱이 uicollectionview 셀의 캐시에서 이미지를로드하는 데 시간이 걸립니다.
라이브러리는 서버와 캐시에서 이미지를 다운로드하지만 내 앱을 종료하고 다시 실행하면 캐시에서 이미지를로드하는 데 시간이 걸립니다. SDWebImage를 사용하여 이미지를로드
코드 (자리 표시 자 이미지는 더욱 때로는 2 ~ 3 초 동안 표시됩니다) : 사용 여기
cell.imgPost.sd_setImage(with: URL(string: (post.lowQualityImgUrl) ?? ""), placeholderImage: UIImage(named:"greybg") , options: .refreshCached, progress: { (recievedSize, expectedSize) in
progressIndicatorView.progress = CGFloat(recievedSize)/CGFloat(expectedSize)
}, completed: { (image, error, cachetype, url) in
if image != nil{
DispatchQueue.main.async {
progresView.removeFromSuperview()
progressIndicatorView.removeFromSuperview()
cell.progressIndicatorView?.isHidden = true
cell.imgPost.image = image
}
}
})
캐싱 옵션이 새로 고침 캐시입니다.
질문 : 컬렉션보기 셀이 sdwebimage를 사용하여 즉시 이미지를로드 할 수없는 이유를 모르겠습니다. 그것은 sdwebimage가 이미지 캐싱을위한 최상의 라이브러리라고 말한 것처럼. 누군가 해결책/문제를 지적 할 수 있습니까?
편집 저는 도서관에 의견을 남겼습니다. 결코 좋은 도서관이라고 생각하지 않습니다. https://github.com/rs/SDWebImage/issues/138
미리 감사드립니다. refreshCached
* 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.
당신은 당신이 동일한 URL에서 다른 이미지를 얻을하지 않는 이미지를 캐시하지 않으려면 refreshCached
를 사용하지 말아야 대한 SDWebImage
문서에서
왜 블록 안에 'cell.imgPost.image = image'를 사용하여 이미지를 다시 설정하고 있습니까? 그것은 이미'cell.imgPost.sd_setImage (with :'블록. – Poles
에 의해 설정되고 있습니다. 만약 cell.imgpost.image = image를 두지 않으면 @Poles 다음에 이미지보기를 스크롤하면 자리 표시 자도 다시 나타납니다. 무엇이 있는지 모르겠습니다. 나는 놓친다 – user3804063