iOS: avoid view's call from non ui thread

This commit is contained in:
pengfei.zhou 2022-07-13 18:42:17 +08:00 committed by osborn
parent 9cb4764bfd
commit b4391cb0d6

View File

@ -126,7 +126,7 @@ - (void)blend:(NSDictionary *)props {
self.loadCallbackId = it; self.loadCallbackId = it;
}]; }];
[super blend:props]; [super blend:props];
if(self.scaleType == 2 && self.view.contentMode != UIViewContentModeScaleAspectFill) { if (self.scaleType == 2 && self.view.contentMode != UIViewContentModeScaleAspectFill) {
self.view.contentMode = UIViewContentModeScaleAspectFill; self.view.contentMode = UIViewContentModeScaleAspectFill;
} }
} }
@ -330,10 +330,11 @@ - (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 DORIC_USE_YYWEBIMAGE #if DORIC_USE_YYWEBIMAGE
UIImage *image = [self currentPlaceHolderImage];
dispatch_async([_YYWebImageSetter setterQueue], ^{ dispatch_async([_YYWebImageSetter setterQueue], ^{
[view yy_cancelCurrentImageRequest]; [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:image 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) {
self.view.contentMode = self.contentMode; self.view.contentMode = self.contentMode;
@ -767,7 +768,7 @@ - (void)reset {
#endif #endif
self.animationEndCallbackId = nil; self.animationEndCallbackId = nil;
} }
#if DORIC_USE_YYWEBIMAGE #if DORIC_USE_YYWEBIMAGE
[self.view yy_cancelCurrentImageRequest]; [self.view yy_cancelCurrentImageRequest];
#elif DORIC_USE_SDWEBIMAGE #elif DORIC_USE_SDWEBIMAGE