From 19232ac4932b6f6d825f44b12ccef74687faba78 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 16 Mar 2016 10:35:53 -0700 Subject: [PATCH] Address pull request comments --- AsyncDisplayKit/ASCollectionView.mm | 11 ++++++----- AsyncDisplayKit/ASDisplayNode.mm | 4 ++++ AsyncDisplayKit/ASTableView.mm | 12 ++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index b1d62a2c3d..fd6dea625b 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -919,14 +919,15 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; { ASCollectionNode *collectionNode = self.collectionNode; if (collectionNode && [collectionNode supportsRangeManagedInterfaceState]) { - // Only use the interfaceStatate of nodes that are range managed + // Only use the interfaceState of nodes that are range managed return collectionNode.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); } - // 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); } - (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 9845309e1e..d5e6aa5ec3 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -1980,6 +1980,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) // subclass override } +/** + * We currently only set interface state on nodes in table/collection views. For other nodes, if they are + * in the hierarchy we enable all ASInterfaceState types with `ASInterfaceStateInHierarchy`, otherwise `None`. + */ - (BOOL)supportsRangeManagedInterfaceState { return ASHierarchyStateIncludesRangeManaged(_hierarchyState); diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index e01c5a521a..886249ab7a 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -796,14 +796,14 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; { ASTableNode *tableNode = self.tableNode; if (tableNode && [tableNode supportsRangeManagedInterfaceState]) { - // Only use the interfaceStatate of nodes that are range managed + // Only use the interfaceState of nodes that are range managed return self.tableNode.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); } - - // 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); } #pragma mark - ASRangeControllerDelegate