iOS: fix when Image async load cause super node requestLayout

This commit is contained in:
pengfei.zhou
2021-11-12 16:23:01 +08:00
committed by osborn
parent af77a0e98e
commit 4c80e5aa60
6 changed files with 42 additions and 16 deletions

View File

@@ -252,11 +252,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale];
#endif
view.image = image;
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
if (self.needReload) {
[self.superNode subNodeContentChanged:self];
}
[node requestLayout];
if (self.loadCallbackId.length > 0) {
if (image) {
[self callJSResponse:self.loadCallbackId,
@@ -326,12 +324,8 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
},
nil];
}
if (async) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
if (async && self.needReload) {
[self.superNode subNodeContentChanged:self];
}
}
}];
@@ -368,12 +362,8 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
},
nil];
}
if (async) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
if (async && self.needReload) {
[self.superNode subNodeContentChanged:self];
}
}
}];
@@ -644,4 +634,15 @@ - (void)reset {
self.blurEffectView = nil;
self.view.contentMode = UIViewContentModeScaleAspectFill;
}
- (BOOL)needReload {
if (self.view.doricLayout.widthSpec == DoricLayoutFit
|| self.view.doricLayout.heightSpec == DoricLayoutFit) {
CGSize size = [self.view sizeThatFits:self.view.bounds.size];
if (!CGSizeEqualToSize(size, self.view.bounds.size)) {
return YES;
}
}
return NO;
}
@end