NetImageView 加载图片失败的处理

This commit is contained in:
zu
2021-11-04 18:05:23 +08:00
parent e407af19de
commit 06b1262740

View File

@@ -11,7 +11,6 @@
@interface NetImageView() @interface NetImageView()
@property (nonatomic, assign, readwrite) NetImageState state; @property (nonatomic, assign, readwrite) NetImageState state;
@property (nonatomic, copy) NSString * innerConfigedUrl; @property (nonatomic, copy) NSString * innerConfigedUrl;
@@ -50,11 +49,14 @@
- (void)loadImage:(UIImage *)placeHolder completion:(LoadCompletion)completion { - (void)loadImage:(UIImage *)placeHolder completion:(LoadCompletion)completion {
self.state = NetImageStateLoading; self.state = NetImageStateLoading;
[self sd_setImageWithURL:[NSURL URLWithString:_innerConfigedUrl] placeholderImage:placeHolder options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [self sd_setImageWithURL:[NSURL URLWithString:_innerConfigedUrl] placeholderImage:placeHolder options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
self.state = NetImageStateLoaded; if (error) {
if (completion) { self.state = NetImageStateUnload;
completion(image, imageURL); } else {
return; self.state = NetImageStateLoaded;
}; if (completion) {
completion(image, imageURL);
};
}
}]; }];
} }