From 8eda2ea2cf0fe19e74951b04a7c4617948a4c6e9 Mon Sep 17 00:00:00 2001 From: hshristov Date: Thu, 3 Sep 2015 14:10:26 +0300 Subject: [PATCH] Fix iOS layout in modal pages. --- CrossPlatformModules.csproj | 18 ++++++++++++++++++ ui/page/page.ios.ts | 24 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 8dbbe83f4..3ceaec96c 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -150,6 +150,15 @@ + + page21.xml + + + page20.xml + + + page19.xml + @@ -157,6 +166,15 @@ + + Designer + + + Designer + + + Designer + diff --git a/ui/page/page.ios.ts b/ui/page/page.ios.ts index bd8e081d0..cf46a2741 100644 --- a/ui/page/page.ios.ts +++ b/ui/page/page.ios.ts @@ -21,7 +21,7 @@ class UIViewControllerImpl extends UIViewController { public didRotateFromInterfaceOrientation(fromInterfaceOrientation: number) { trace.write(this._owner + " didRotateFromInterfaceOrientation(" + fromInterfaceOrientation + ")", trace.categories.ViewHierarchy); - if ((this._owner)._isModal) { + if (this._owner._isModal) { var parentBounds = (this._owner)._UIModalPresentationFormSheet ? (this._owner._nativeView).superview.bounds : UIScreen.mainScreen().bounds; utils.ios._layoutRootView(this._owner, parentBounds); } @@ -35,7 +35,13 @@ class UIViewControllerImpl extends UIViewController { public viewDidLayoutSubviews() { trace.write(this._owner + " viewDidLayoutSubviews, isLoaded = " + this._owner.isLoaded, trace.categories.ViewHierarchy); - this._owner._updateLayout(); + if (this._owner._isModal) { + var parentBounds = (this._owner)._UIModalPresentationFormSheet ? this._owner._nativeView.superview.bounds : UIScreen.mainScreen().bounds; + utils.ios._layoutRootView(this._owner, parentBounds); + } + else { + this._owner._updateLayout(); + } } public viewWillAppear() { @@ -56,12 +62,20 @@ class UIViewControllerImpl extends UIViewController { export class Page extends pageCommon.Page { private _ios: UIViewController; public _enableLoadedEvents: boolean; + public _isModal: boolean = false; constructor(options?: definition.Options) { super(options); this._ios = UIViewControllerImpl.new().initWithOwner(this); } + public requestLayout(): void { + super.requestLayout(); + if (!this.parent && this.ios && this._nativeView) { + this._nativeView.setNeedsLayout(); + } + } + public _onContentChanged(oldView: viewModule.View, newView: viewModule.View) { super._onContentChanged(oldView, newView); this._removeNativeView(oldView); @@ -110,12 +124,12 @@ export class Page extends pageCommon.Page { return this._ios; } - get _nativeView(): any { + get _nativeView(): UIView { return this.ios.view; } protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) { - (this)._isModal = true; + this._isModal = true; if (!parent.ios.view.window) { throw new Error("Parent page is not part of the window hierarchy. Close the current modal page before showing another one!"); @@ -143,7 +157,7 @@ export class Page extends pageCommon.Page { protected _hideNativeModalView(parent: Page) { parent._ios.dismissModalViewControllerAnimated(false); - (this)._isModal = false; + this._isModal = false; (this)._UIModalPresentationFormSheet = false; }