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];\ }\ }\ });\