как что-то сделать сразу после загрузки изображения с помощью SDWebImage? - PullRequest
0 голосов
/ 11 июля 2020

Итак, я хочу показать сообщение пользователю сразу после того, как изображение будет загружено и установлено в ImageView. Я использую SDWebImage. как это сделать?

Вот мой текущий код

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

Ответы [ 2 ]

2 голосов
/ 11 июля 2020

Можно так

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
}
0 голосов
/ 13 июля 2020

Это 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")
       }

}
...