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;
}];
[super blend:props];
if(self.scaleType == 2 && self.view.contentMode != UIViewContentModeScaleAspectFill) {
if (self.scaleType == 2 && 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;
view.doricLayout.undefined = YES;
#if DORIC_USE_YYWEBIMAGE
UIImage *image = [self currentPlaceHolderImage];
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:image options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
__strong typeof(_self) self = _self;
if (self.placeHolderColor || self.errorColor) {
self.view.contentMode = self.contentMode;