簡體   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