iOS:fix item count change cause reload crash
This commit is contained in:
parent
414f25d8fd
commit
bc6f9fac9b
@ -225,11 +225,14 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
|
|||||||
if (old && [old isEqualToNumber:@(height)]) {
|
if (old && [old isEqualToNumber:@(height)]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
NSUInteger currentCount = self.itemCount + (self.loadMore ? 1 : 0);
|
||||||
self.itemHeights[@(position)] = @(height);
|
self.itemHeights[@(position)] = @(height);
|
||||||
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){
|
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
|
||||||
|
if ([self.view numberOfRowsInSection:0] <= position || currentCount != itemCount) {
|
||||||
|
[self.view reloadData];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
|
||||||
|
Reference in New Issue
Block a user