iOS:fix item count change cause reload crash
This commit is contained in:
parent
414f25d8fd
commit
bc6f9fac9b
@ -139,7 +139,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
|||||||
DoricListItemNode *listItemNode = [[DoricListItemNode alloc] initWithContext:self.doricContext];
|
DoricListItemNode *listItemNode = [[DoricListItemNode alloc] initWithContext:self.doricContext];
|
||||||
[listItemNode initWithSuperNode:self];
|
[listItemNode initWithSuperNode:self];
|
||||||
cell.doricListItemNode = listItemNode;
|
cell.doricListItemNode = listItemNode;
|
||||||
cell.backgroundColor=[UIColor clearColor];
|
cell.backgroundColor = [UIColor clearColor];
|
||||||
listItemNode.view.width = tableView.width;
|
listItemNode.view.width = tableView.width;
|
||||||
[cell.contentView addSubview:listItemNode.view];
|
[cell.contentView addSubview:listItemNode.view];
|
||||||
}
|
}
|
||||||
@ -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