iOS:Fix ListNode cannot measure content height properly

This commit is contained in:
pengfei.zhou
2021-04-14 12:39:38 +08:00
committed by osborn
parent 4873ff535d
commit b762b9db4b
3 changed files with 28 additions and 4 deletions

View File

@@ -296,6 +296,13 @@ - (void)callItem:(NSUInteger)position size:(CGSize)size {
return;
}
self.itemSizeInfo[@(position)] = [NSValue valueWithCGSize:size];
if (self.view.doricLayout.widthSpec == DoricLayoutFit || self.view.doricLayout.heightSpec == DoricLayoutFit) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
}
[self.view.collectionViewLayout invalidateLayout];
}

View File

@@ -35,6 +35,9 @@ @interface DoricTableView : UITableView
@end
@implementation DoricTableView
- (CGSize)sizeThatFits:(CGSize)size {
return [super sizeThatFits:size];
}
@end
@@ -232,7 +235,7 @@ - (void)blendSubNode:(NSDictionary *)subModel {
@try {
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
@catch(id exception) {
@catch (id exception) {
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
}
}];
@@ -251,6 +254,13 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
self.itemHeights[@(position)] = @(height);
if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
if (self.view.doricLayout.heightSpec == DoricLayoutFit) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
}
[UIView performWithoutAnimation:^{
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
if (itemCount <= position || currentCount != itemCount) {
@@ -261,13 +271,20 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
@try {
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
@catch(id exception) {
@catch (id exception) {
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
}
}];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
if (self.view.doricLayout.heightSpec == DoricLayoutFit) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
}
[self.view reloadData];
});
}