File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,12 @@ public final class Flex {
58
58
//
59
59
60
60
/**
61
- This method adds a flex item (UIView) to a flex container. Internally the methods adds the UIView has subviews and enables flexbox.
61
+ Adds a flex item (`UIView`) to the receiver and returns the item's flex interface.
62
+
63
+ This method internally creates a new `UIView` instance corresponding to the flex item,
64
+ and is useful for adding a flex item/container when you don't need to refer to it later.
62
65
63
- - Returns: The added view flex interface
66
+ - Returns: The flex interface corresponding to the added view.
64
67
*/
65
68
@discardableResult
66
69
public func addItem( ) -> Flex {
@@ -69,11 +72,12 @@ public final class Flex {
69
72
}
70
73
71
74
/**
72
- This method is similar to `addItem(: UIView)` except that it also creates the flex item's UIView. Internally the method creates an
73
- UIView, adds it has subviews and enables flexbox. This is useful to add a flex item/container easily when you don't need to refer to it later.
75
+ Adds a flex item (`UIView`) to the receiver and returns the item's flex interface.
76
+
77
+ This method enables flexbox for `view` and adds it as a subview of the receiver's associated host view.
74
78
75
- - Parameter view: view to add to the flex container
76
- - Returns: The added view flex interface
79
+ - Parameter view: The view to be added.
80
+ - Returns: The flex interface corresponding to the added view.
77
81
*/
78
82
@discardableResult
79
83
public func addItem( _ view: UIView ) -> Flex {
Original file line number Diff line number Diff line change @@ -489,7 +489,12 @@ static void YGAttachNodesFromViewHierachy(UIView* const view) {
489
489
if (!YGNodeHasExactSameChildren (node, subviewsToInclude)) {
490
490
YGRemoveAllChildren (node);
491
491
for (int i = 0 ; i < subviewsToInclude.count ; i++) {
492
- YGNodeInsertChild (node, subviewsToInclude[i].yoga .node , i);
492
+ YGNodeRef child = subviewsToInclude[i].yoga .node ;
493
+ YGNodeRef parent = YGNodeGetParent (child);
494
+ if (parent != NULL ) {
495
+ YGNodeRemoveChild (parent, child);
496
+ }
497
+ YGNodeInsertChild (node, child, i);
493
498
}
494
499
}
495
500
You can’t perform that action at this time.
0 commit comments