ios - 如何在 SDwebimage 中使用成功和失败 block

标签 ios iphone ios6 ios7 sdwebimage

我有最新版本的 SDWebimage 但它没有成功和失败 我尝试了以下方法,但 SDwebimage 没有方法

[self.imageView setImageWithURL:[NSURL URLWithString:self.imageURL]
              placeholderImage:[UIImage imageNamed:@"YourPlaceholder.png"]
                       success:^(UIImage *image) {
                           // remove animation

                       }
                       failure:^(NSError *error) {
                           NSLog(@"thumbnail error: %@",error);
                           // handle failed download

                       }];

有谁知道如何在 SDwebimage setImageWithURL 或任何其他替代方法中添加成功和失败 block 如果从 URL 获取图像时出现错误,我想处理

最佳答案

试试这个:

[self.imageView setImageWithURL:[NSURL URLWithString:imageURL]
                   placeholderImage:[UIImage imageNamed:@"YourPlaceholder.png"]
                          completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                              //... completion code here ...
                          }];

关于ios - 如何在 SDwebimage 中使用成功和失败 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22320868/

相关文章:

iOS 11 相机扫描二维码并将其传递到网站

ios - 无法通过 iOS 中的 AVPlayer 播放文档目录中的音乐?

javascript - css webkit column 访问单列

IOS:恢复 View Controller

ios - 视频缩略图需要 10-15 秒才能显示

xcode - 无需使用转场就需要交叉溶解过渡

iphone - 搜索不起作用

iphone - 在 iphone safari webapp 中隐藏键盘

ios - Instagram ios 在 ios 6.0 中 Hook

iphone - 有谁知道在 IOS 6.0 中不推荐使用哪些方法?