iOS:Fix ListNode cannot measure content height properly
This commit is contained in:
parent
4873ff535d
commit
b762b9db4b
@ -50,9 +50,9 @@ class ListVH extends ViewHolder {
|
|||||||
itemCount: 0,
|
itemCount: 0,
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
widthSpec: LayoutSpec.MOST,
|
widthSpec: LayoutSpec.MOST,
|
||||||
heightSpec: LayoutSpec.JUST,
|
heightSpec: LayoutSpec.FIT,
|
||||||
weight: 1
|
|
||||||
},
|
},
|
||||||
|
backgroundColor: Color.YELLOW,
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
|
@ -296,6 +296,13 @@ - (void)callItem:(NSUInteger)position size:(CGSize)size {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.itemSizeInfo[@(position)] = [NSValue valueWithCGSize:size];
|
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];
|
[self.view.collectionViewLayout invalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@ @interface DoricTableView : UITableView
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricTableView
|
@implementation DoricTableView
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
|
return [super sizeThatFits:size];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@ -232,7 +235,7 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
|||||||
@try {
|
@try {
|
||||||
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
||||||
}
|
}
|
||||||
@catch(id exception) {
|
@catch (id exception) {
|
||||||
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
|
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@ -251,6 +254,13 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
|
|||||||
self.itemHeights[@(position)] = @(height);
|
self.itemHeights[@(position)] = @(height);
|
||||||
if (@available(iOS 10.0, *)) {
|
if (@available(iOS 10.0, *)) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
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:^{
|
[UIView performWithoutAnimation:^{
|
||||||
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
|
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
|
||||||
if (itemCount <= position || currentCount != itemCount) {
|
if (itemCount <= position || currentCount != itemCount) {
|
||||||
@ -261,13 +271,20 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
|
|||||||
@try {
|
@try {
|
||||||
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
||||||
}
|
}
|
||||||
@catch(id exception) {
|
@catch (id exception) {
|
||||||
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
|
[self.doricContext.driver.registry onException:exception inContext:self.doricContext];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
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];
|
[self.view reloadData];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user