SDWebImage, Swift: SDWebImageRefreshCached unresolved identifier

假如想象 提交于 2019-12-12 18:31:05

问题


Strange.. something simple that is in the docs doesn't seem to work with Swift. See below code. Where exactly is "SDWebImageRefreshCached" when using Swift??

self.profileImageView.sd_setImageWithURL(profileImageUrl, placeholderImage:  UIImage(named: "default_profile_image"), options: SDWebImageRefreshCached)

回答1:


In Swift, the enums are exposed slightly differently.

You would be looking for SDWebImageOptions.RefreshCached, or .RefreshCached for short.

Your line of code thus would be:

self.profileImageView.sd_setImageWithURL(profileImageUrl, placeholderImage:  UIImage(named: "default_profile_image"), options: .RefreshCached)



回答2:


You can try this code:

.RefreshCached is change to .refreshCached in SDWebImage 4.0.0

//SDWebImage 4.0.0
self.profileImageView.sd_setImage(with: yourImageUrl, placeholderImage: UIImage("Your placeholder image name"), options: .refreshCached)


来源:https://stackoverflow.com/questions/35248040/sdwebimage-swift-sdwebimagerefreshcached-unresolved-identifier

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!