Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore call pattern where UIView methods drive __enterHierarchy and __exitHierarchy for view-backed nodes #1561

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1722,10 +1722,14 @@ - (void)subnodeDisplayDidFinish:(ASDisplayNode *)subnode

- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
{
if (event == kCAOnOrderIn) {
[self __enterHierarchy];
} else if (event == kCAOnOrderOut) {
[self __exitHierarchy];
// Only drive __enterHierarchy and __exitHierarchy if the node is layer-backed.
// View-backed nodes handle them in _ASDisplayView's -willMoveToWindow: and -didMoveToWindow.
if (self.isLayerBacked) {
if (event == kCAOnOrderIn) {
[self __enterHierarchy];
} else if (event == kCAOnOrderOut) {
[self __exitHierarchy];
}
}

return [self layerActionForKey:event];
Expand Down
18 changes: 18 additions & 0 deletions Source/Details/_ASDisplayView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ - (NSString *)description
return nodeAction;
}

- (void)willMoveToWindow:(UIWindow *)newWindow
{
ASDisplayNode *node = _asyncdisplaykit_node; // Create strong reference to weak ivar.
BOOL visible = (newWindow != nil);
if (visible && !node.inHierarchy) {
[node __enterHierarchy];
}
}

- (void)didMoveToWindow
{
ASDisplayNode *node = _asyncdisplaykit_node; // Create strong reference to weak ivar.
BOOL visible = (self.window != nil);
if (!visible && node.inHierarchy) {
[node __exitHierarchy];
}
}

- (void)willMoveToSuperview:(UIView *)newSuperview
{
// Keep the node alive while the view is in a view hierarchy. This helps ensure that async-drawing views can always
Expand Down