diff --git a/ui/core/view.ios.ts b/ui/core/view.ios.ts index 33adf9c67..1b3bcaa44 100644 --- a/ui/core/view.ios.ts +++ b/ui/core/view.ios.ts @@ -271,7 +271,7 @@ export class View extends viewCommon.View { if (superview && this._nativeView) { var types = require("utils/types"); - if (types.isNullOrUndefined(atIndex) || atIndex >= this._nativeView.subviews.count) { + if (types.isNullOrUndefined(atIndex) || atIndex >= superview.subviews.count) { superview.addSubview(this._nativeView); } else { superview.insertSubviewAtIndex(this._nativeView, atIndex); diff --git a/ui/layouts/dock-layout/dock-layout.ios.ts b/ui/layouts/dock-layout/dock-layout.ios.ts index 8843994e9..9088dec79 100644 --- a/ui/layouts/dock-layout/dock-layout.ios.ts +++ b/ui/layouts/dock-layout/dock-layout.ios.ts @@ -100,7 +100,13 @@ export class DockLayout extends common.DockLayout { let childWidth = child.getMeasuredWidth() + (lp.leftMargin + lp.rightMargin) * density; let childHeight = child.getMeasuredHeight() + (lp.topMargin + lp.bottomMargin) * density; - + + if (last && this.stretchLastChild) { + // Last child with stretch - give it all the space and return; + View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight); + return; + } + let dock = DockLayout.getDock(child); switch (dock) { case Dock.top: @@ -135,11 +141,7 @@ export class DockLayout extends common.DockLayout { break; } - if (!last) { - View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight); - } else { - View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight); - } + View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight); }); DockLayout.restoreOriginalParams(this);