From bc6f9fac9b9f347badc3989df51a4358550b202f Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 24 Jul 2020 18:11:41 +0800 Subject: [PATCH] iOS:fix item count change cause reload crash --- doric-iOS/Pod/Classes/Shader/DoricListNode.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index c11a72f2..3bd863d5 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -139,7 +139,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N DoricListItemNode *listItemNode = [[DoricListItemNode alloc] initWithContext:self.doricContext]; [listItemNode initWithSuperNode:self]; cell.doricListItemNode = listItemNode; - cell.backgroundColor=[UIColor clearColor]; + cell.backgroundColor = [UIColor clearColor]; listItemNode.view.width = tableView.width; [cell.contentView addSubview:listItemNode.view]; } @@ -225,11 +225,14 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height { if (old && [old isEqualToNumber:@(height)]) { return; } + NSUInteger currentCount = self.itemCount + (self.loadMore ? 1 : 0); self.itemHeights[@(position)] = @(height); if (@available(iOS 10.0, *)) { dispatch_async(dispatch_get_main_queue(), ^{ [UIView performWithoutAnimation:^{ - if([self.view numberOfRowsInSection:0]<=position){ + NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0); + if ([self.view numberOfRowsInSection:0] <= position || currentCount != itemCount) { + [self.view reloadData]; return; } NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];