From 774cacc0fcbd8f595cf6c9728feb09f7a66f0293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 12 Mar 2021 11:11:47 +0800 Subject: [PATCH] fix crash --- doric-iOS/Pod/Classes/Shader/DoricListNode.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index 745c6ef7..16b44bca 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -207,6 +207,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position { - (void)blendSubNode:(NSDictionary *)subModel { ///Here async blend sub node because the item count need to be applied first. + NSUInteger currentCount = self.itemCount + (self.loadMore ? 1 : 0); dispatch_async(dispatch_get_main_queue(), ^{ NSString *viewId = subModel[@"id"]; DoricViewNode *viewNode = [self subNodeWithViewId:viewId]; @@ -220,8 +221,13 @@ - (void)blendSubNode:(NSDictionary *)subModel { [self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) { if ([viewId isEqualToString:obj]) { *stop = YES; - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[key integerValue] inSection:0]; [UIView performWithoutAnimation:^{ + NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0); + if (itemCount <= [key integerValue] || currentCount != itemCount) { + [self.view reloadData]; + return; + } + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[key integerValue] inSection:0]; [self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; }]; }