diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 821e21ddca..a7ab280e25 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -1002,6 +1002,7 @@ - (ASRangeController *)rangeController - (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeController { ASDisplayNodeAssertMainThread(); + // Calling visibleNodeIndexPathsForRangeController: will trigger UIKit to call reloadData if it never has, which can result // in incorrect layout if performed at zero size. We can use the fact that nothing can be visible at zero size to return fast. BOOL isZeroSized = CGRectEqualToRect(self.bounds, CGRectZero); @@ -1065,6 +1066,11 @@ - (void)rangeController:(ASRangeController *)rangeController didEndUpdatesAnimat _performingBatchUpdates = NO; } +- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController +{ + [self _checkForBatchFetching]; +} + - (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions { ASDisplayNodeAssertMainThread(); diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index b8a174bbdd..871589b49d 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -968,6 +968,11 @@ - (void)rangeController:(ASRangeController *)rangeController didEndUpdatesAnimat } } +- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController +{ + [self _checkForBatchFetching]; +} + - (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions { ASDisplayNodeAssertMainThread(); diff --git a/AsyncDisplayKit/Details/ASRangeController.h b/AsyncDisplayKit/Details/ASRangeController.h index 2de7e3ce4f..c79124a961 100644 --- a/AsyncDisplayKit/Details/ASRangeController.h +++ b/AsyncDisplayKit/Details/ASRangeController.h @@ -146,6 +146,13 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)rangeController:(ASRangeController * )rangeController didEndUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion; +/** + * Completed updates to cell node addition and removal. + * + * @param rangeController Sender. + */ +- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController; + /** * Called for nodes insertion. * diff --git a/AsyncDisplayKit/Details/ASRangeController.mm b/AsyncDisplayKit/Details/ASRangeController.mm index 436cb8f409..6c84935540 100644 --- a/AsyncDisplayKit/Details/ASRangeController.mm +++ b/AsyncDisplayKit/Details/ASRangeController.mm @@ -333,6 +333,7 @@ - (void)_updateVisibleNodeIndexPaths [modifiedIndexPaths sortUsingSelector:@selector(compare:)]; NSLog(@"Range update complete; modifiedIndexPaths: %@", [self descriptionWithIndexPaths:modifiedIndexPaths]); #endif + [_delegate didCompleteUpdatesInRangeController:self]; } #pragma mark - Notification observers