So, I want to show a message to the user right after an image is downloaded and set in ImageView. I am using SDWebImage. how to do that?
Here is my current code
profilePictureImageView.sd_setImage(with: referenceImage, placeholderImage: UIImage(named: ImageName.defaultProfilePicture))
You can do it like this
profilePictureImageView.sd_setImage(with: referenceImage, placeholderImage: UIImage(named: "cod_logo"), options: [.highPriority]) { (image, error, cashtype, url) in
if image != nil{
// Do something Here after load image
}
print(error) // Your error is here
}
This is pod 'SDWebImage' = '4.0.0'
and XCode == 11.3.1
self.userAvatar.sd_setImage(with: URL(string: __user_avatar), placeholderImage: UIImage(named: "UserDefalutAvatar"), options: .progressiveDownload, progress: { (receivedSize, expectedSize, targetURL) in
print("The progress value for the downloading is \(receivedSize)")
}) { (downloadedImage, downloadedError, imageCacheType, downloadedURL) in
if let _downloadedError = downloadedError {
print("Download image encountered error. \(_downloadedError.localizedDescription)")
return
}
if let _downloadedImage = downloadedImage {
print("This is downloaded image, you can do it what you want")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.