Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 1e8c707

Browse files
committed
Merge pull request #1083 from facebook/ASTableCollectionVisibility
Restore full functionality of the display / data ranges when not using the Node variants of Table / Collection.
2 parents bd8ba38 + b989be6 commit 1e8c707

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,15 @@ - (CGSize)viewportSizeForRangeController:(ASRangeController *)rangeController
801801

802802
- (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController
803803
{
804-
return self.collectionNode.interfaceState;
804+
ASCollectionNode *collectionNode = self.collectionNode;
805+
if (collectionNode) {
806+
return self.collectionNode.interfaceState;
807+
} else {
808+
// Until we can always create an associated ASCollectionNode without a retain cycle,
809+
// we might be on our own to try to guess if we're visible. The node normally
810+
// handles this even if it is the root / directly added to the view hierarchy.
811+
return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone);
812+
}
805813
}
806814

807815
- (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths

AsyncDisplayKit/ASTableView.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,15 @@ - (CGSize)viewportSizeForRangeController:(ASRangeController *)rangeController
722722

723723
- (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController
724724
{
725-
return self.tableNode.interfaceState;
725+
ASTableNode *tableNode = self.tableNode;
726+
if (tableNode) {
727+
return self.tableNode.interfaceState;
728+
} else {
729+
// Until we can always create an associated ASTableNode without a retain cycle,
730+
// we might be on our own to try to guess if we're visible. The node normally
731+
// handles this even if it is the root / directly added to the view hierarchy.
732+
return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone);
733+
}
726734
}
727735

728736
#pragma mark - ASRangeControllerDelegate

0 commit comments

Comments
 (0)