iOS:fix item count change cause reload crash

This commit is contained in:
pengfei.zhou 2020-07-24 18:11:41 +08:00 committed by osborn
parent 414f25d8fd
commit bc6f9fac9b

View File

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