[ASDisplayNode] Remove node from supernode before adding it as a subview (#2746)

* [ASDisplayNode] Remove node from supernode before adding it as a subview

If a node is being added as a subview to a UIVIew, we must make sure to remove it as a subnode of its supernode.

* remove from supernode if adding to a layer.
This commit is contained in:
ricky
2016-12-13 09:34:05 -08:00
committed by appleguy
parent ab5627b9e3
commit 8920b60dcd

View File

@@ -3876,6 +3876,9 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
if (selfNode) {
[selfNode addSubnode:subnode];
} else {
if (subnode.supernode) {
[subnode removeFromSupernode];
}
[self addSubview:subnode.view];
}
}
@@ -3891,6 +3894,9 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
if (selfNode) {
[selfNode addSubnode:subnode];
} else {
if (subnode.supernode) {
[subnode removeFromSupernode];
}
[self addSublayer:subnode.layer];
}
}