diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 2bea600250..5e8b7c03b1 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -801,7 +801,15 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; - (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController { - return self.collectionNode.interfaceState; + ASCollectionNode *collectionNode = self.collectionNode; + if (collectionNode) { + return self.collectionNode.interfaceState; + } else { + // Until we can always create an associated ASCollectionNode without a retain cycle, + // we might be on our own to try to guess if we're visible. The node normally + // handles this even if it is the root / directly added to the view hierarchy. + return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone); + } } - (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index af0c9dddd6..289fdc295b 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -722,7 +722,15 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; - (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController { - return self.tableNode.interfaceState; + ASTableNode *tableNode = self.tableNode; + if (tableNode) { + return self.tableNode.interfaceState; + } else { + // Until we can always create an associated ASTableNode without a retain cycle, + // we might be on our own to try to guess if we're visible. The node normally + // handles this even if it is the root / directly added to the view hierarchy. + return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone); + } } #pragma mark - ASRangeControllerDelegate