iOS: fix quickly set image url caused image integrity error

This commit is contained in:
王劲鹏 2021-09-07 10:46:27 +08:00 committed by osborn
parent f63da7a98a
commit d62303baf0

View File

@ -28,6 +28,7 @@
#if __has_include(<YYWebImage/YYWebImage.h>) #if __has_include(<YYWebImage/YYWebImage.h>)
#import <YYWebImage/YYWebImage.h> #import <YYWebImage/YYWebImage.h>
#import <YYWebImage/_YYWebImageSetter.h>
@interface DoricImageView : YYAnimatedImageView @interface DoricImageView : YYAnimatedImageView
@end @end
@ -236,6 +237,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
__block BOOL async = NO; __block BOOL async = NO;
view.doricLayout.undefined = YES; view.doricLayout.undefined = YES;
#if __has_include(<YYWebImage/YYWebImage.h>) #if __has_include(<YYWebImage/YYWebImage.h>)
dispatch_async([_YYWebImageSetter setterQueue], ^{
[view yy_cancelCurrentImageRequest];
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) { [view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
__strong typeof(_self) self = _self; __strong typeof(_self) self = _self;
if (self.placeHolderColor || self.errorColor) { if (self.placeHolderColor || self.errorColor) {
@ -268,6 +272,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
} }
} }
}]; }];
});
#elif __has_include(<SDWebImage/SDWebImage.h>) #elif __has_include(<SDWebImage/SDWebImage.h>)
[view sd_setImageWithURL:[NSURL URLWithString:prop] [view sd_setImageWithURL:[NSURL URLWithString:prop]
placeholderImage:[self currentPlaceHolderImage] placeholderImage:[self currentPlaceHolderImage]