SDWebImage, Swift: SDWebImageRefreshCached unresol

2019-07-15 08:37发布

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)

2条回答
Evening l夕情丶
2楼-- · 2019-07-15 08:40

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)
查看更多
别忘想泡老子
3楼-- · 2019-07-15 08:50

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)
查看更多
登录 后发表回答