From 3b4e8d732cfd30fdd0b4e3af65c6f7faa98ace9f Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 16 Mar 2016 11:45:22 -0700 Subject: [PATCH] Improve way to detect interface state of ASCollectionView and ASTableView --- AsyncDisplayKit/ASCollectionView.mm | 6 +++--- AsyncDisplayKit/ASTableView.mm | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index fd6dea625b..e535728834 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -920,14 +920,14 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; ASCollectionNode *collectionNode = self.collectionNode; if (collectionNode && [collectionNode supportsRangeManagedInterfaceState]) { // Only use the interfaceState of nodes that are range managed - return collectionNode.interfaceState; + ASInterfaceState interfaceState = collectionNode.interfaceState; + return (self.window == nil ? (interfaceState &= (~ASInterfaceStateVisible)) : interfaceState); } else { // For not range managed nodes or 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); + return (self.window == nil ? ASInterfaceStateNone : (ASInterfaceStateVisible | ASInterfaceStateDisplay)); } - } - (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 886249ab7a..734a867e79 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -797,12 +797,13 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; ASTableNode *tableNode = self.tableNode; if (tableNode && [tableNode supportsRangeManagedInterfaceState]) { // Only use the interfaceState of nodes that are range managed - return self.tableNode.interfaceState; + ASInterfaceState interfaceState = self.tableNode.interfaceState; + return (self.window == nil ? (interfaceState &= (~ASInterfaceStateVisible)) : interfaceState); } else { // For not range managed nodes or 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); + return (self.window == nil ? ASInterfaceStateNone : (ASInterfaceStateVisible | ASInterfaceStateDisplay)); } }