From dda7accd8e38a86327e043fb3402e2a80636954e Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Fri, 15 Jul 2016 16:32:23 -0700 Subject: [PATCH] [ASCollectionView] When resizing, invalidate after remeasuring all nodes (#1931) --- AsyncDisplayKit/ASCollectionView.mm | 10 +++++----- AsyncDisplayKit/Details/ASEnvironment.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 7d57011c74..8b2a4adac5 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -100,7 +100,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; id _layoutFacilitator; BOOL _performingBatchUpdates; - BOOL _superPerformingBatchUpdates; + NSUInteger _superBatchUpdateCount; NSMutableArray *_batchUpdateBlocks; BOOL _isDeallocating; @@ -518,11 +518,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; - (void)_superPerformBatchUpdates:(void(^)())updates completion:(void(^)(BOOL finished))completion { ASDisplayNodeAssertMainThread(); - ASDisplayNodeAssert(_superPerformingBatchUpdates == NO, @"Nested batch updates being sent to UICollectionView. This is not expected."); - _superPerformingBatchUpdates = YES; + _superBatchUpdateCount++; [super performBatchUpdates:updates completion:completion]; - _superPerformingBatchUpdates = NO; + _superBatchUpdateCount--; } #pragma mark Assertions. @@ -849,6 +848,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; } completion:nil]; // We need to ensure the size requery is done before we update our layout. [self waitUntilAllUpdatesAreCommitted]; + [self.collectionViewLayout invalidateLayout]; } } @@ -857,7 +857,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; _nextLayoutInvalidationStyle = ASCollectionViewInvalidationStyleNone; switch (invalidationStyle) { case ASCollectionViewInvalidationStyleWithAnimation: - if (!_superPerformingBatchUpdates) { + if (0 == _superBatchUpdateCount) { [self _superPerformBatchUpdates:^{ } completion:nil]; } break; diff --git a/AsyncDisplayKit/Details/ASEnvironment.h b/AsyncDisplayKit/Details/ASEnvironment.h index e42c26534e..486f9f8852 100644 --- a/AsyncDisplayKit/Details/ASEnvironment.h +++ b/AsyncDisplayKit/Details/ASEnvironment.h @@ -153,7 +153,6 @@ ASDISPLAYNODE_EXTERN_C_END for (NSArray *sectionArray in completedNodes) {\ for (ASCellNode *cellNode in sectionArray) {\ ASEnvironmentStatePropagateDown(cellNode, currentTraits);\ - [cellNode setNeedsLayout];\ }\ }\ });\