Ignore Relayout Requests for Deleted Cell Nodes (#279)

* Data Controller: Ignore relayout requests for elements that have been deleted in the mean-time.

* Bolster our logchange

* Add sanity check
This commit is contained in:
Adlai Holler
2017-05-16 11:31:15 -07:00
committed by GitHub
parent e6accc7ea6
commit 432018cfdc
5 changed files with 24 additions and 5 deletions

View File

@@ -1664,9 +1664,12 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
- (BOOL)dataController:(ASDataController *)dataController presentedSizeForElement:(ASCollectionElement *)element matchesSize:(CGSize)size
{
NSIndexPath *indexPath = [self indexPathForNode:element.node];
if (indexPath == nil) {
ASDisplayNodeFailAssert(@"Data controller should not ask for presented size for element that is not presented.");
return YES;
}
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
CGRect rect = attributes.frame;
return CGSizeEqualToSizeWithIn(rect.size, size, FLT_EPSILON);
return CGSizeEqualToSizeWithIn(attributes.size, size, FLT_EPSILON);
}