iOS: when cell height not zero don't remove

This commit is contained in:
王劲鹏 2023-08-11 20:19:03 +08:00 committed by osborn
parent 2e7fe08764
commit ff92ac5b16

View File

@ -174,7 +174,13 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
[self removeSubModel:obj];
}];
[self.itemViewIds removeAllObjects];
[self.itemHeights removeAllObjects];
NSMutableDictionary *map = self.itemHeights.mutableCopy;
[self.itemHeights enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSNumber *obj, BOOL * _Nonnull stop) {
if ([obj isEqualToNumber:@(0)]) {
[map removeObjectForKey:key];
}
}];
self.itemHeights = map.mutableCopy;
self.needReload = true;
}
} else if ([@"batchCount" isEqualToString:name]) {
@ -724,7 +730,13 @@ - (void)reload {
[self removeSubModel:obj];
}];
[self.itemViewIds removeAllObjects];
[self.itemHeights removeAllObjects];
NSMutableDictionary *map = self.itemHeights.mutableCopy;
[self.itemHeights enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSNumber *obj, BOOL * _Nonnull stop) {
if ([obj isEqualToNumber:@(0)]) {
[map removeObjectForKey:key];
}
}];
self.itemHeights = map.mutableCopy;
dispatch_async(dispatch_get_main_queue(), ^{
self.rowCount = self.itemCount + (self.loadMore ? 1 : 0);
[self.view reloadData];