Refactor calculation of interface state based on ASDisplayNode and window

This commit is contained in:
Michael Schneider
2016-03-16 13:26:17 -07:00
parent 3b4e8d732c
commit 8d771f930a
4 changed files with 19 additions and 22 deletions

View File

@@ -794,17 +794,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController
{
ASTableNode *tableNode = self.tableNode;
if (tableNode && [tableNode supportsRangeManagedInterfaceState]) {
// Only use the interfaceState of nodes that are range managed
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 ? ASInterfaceStateNone : (ASInterfaceStateVisible | ASInterfaceStateDisplay));
}
return ASInterfaceStateForDisplayNode(self.tableNode, self.window);
}
#pragma mark - ASRangeControllerDelegate