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 {
5858 //
5959
6060 /**
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.
6265
63- - Returns: The added view flex interface
66+ - Returns: The flex interface corresponding to the added view.
6467 */
6568 @discardableResult
6669 public func addItem( ) -> Flex {
@@ -69,11 +72,12 @@ public final class Flex {
6972 }
7073
7174 /**
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.
7478
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.
7781 */
7882 @discardableResult
7983 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) {
489489 if (!YGNodeHasExactSameChildren (node, subviewsToInclude)) {
490490 YGRemoveAllChildren (node);
491491 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);
493498 }
494499 }
495500
You can’t perform that action at this time.
0 commit comments