繁体   English   中英

使用 SDWebImage 下载图像后如何立即执行操作?

[英]how to do something right after downloading image using SDWebImage?

所以,我想在下载图像并在 ImageView 中设置后立即向用户显示一条消息。 我正在使用 SDWebImage。 怎么做?

这是我当前的代码

    profilePictureImageView.sd_setImage(with: referenceImage, placeholderImage: UIImage(named: ImageName.defaultProfilePicture))

你可以这样做

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
}

这是pod 'SDWebImage' = '4.0.0'和 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")
       }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM