fix:iOS ListNode item index outof range

This commit is contained in:
pengfei.zhou 2020-07-13 11:25:04 +08:00 committed by osborn
parent 77281b945f
commit 5113d73b37

View File

@ -226,10 +226,13 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
return; return;
} }
self.itemHeights[@(position)] = @(height); self.itemHeights[@(position)] = @(height);
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
if (@available(iOS 10.0, *)) { if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
if([self.view numberOfRowsInSection:0]<=position){
return;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; [self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}]; }];
}); });