fix crash

This commit is contained in:
王劲鹏 2021-03-12 11:11:47 +08:00 committed by osborn
parent bd0f155360
commit 774cacc0fc

View File

@ -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];
}];
}