diff --git a/ui/frame/frame.ios.ts b/ui/frame/frame.ios.ts index d43a4ee58..42459943d 100644 --- a/ui/frame/frame.ios.ts +++ b/ui/frame/frame.ios.ts @@ -206,7 +206,11 @@ export class Frame extends frameCommon.Frame { } public measurePage(page: pages.Page): { measuredWidth: number; measuredHeight: number } { - + if (page && (page)._viewWillDisappear) { + //https://github.com/NativeScript/NativeScript/issues/1201 + return { measuredWidth: undefined, measuredHeight: undefined }; + } + // If background does not span under statusbar - reduce available height. let heightSpec: number = this._heightMeasureSpec; if (page && !page.backgroundSpanUnderStatusBar && !this.parent) { @@ -229,6 +233,11 @@ export class Frame extends frameCommon.Frame { } public layoutPage(page: pages.Page): void { + if (page && (page)._viewWillDisappear) { + //https://github.com/NativeScript/NativeScript/issues/1201 + return; + } + // If background does not span under statusbar - reduce available height and adjust top offset. let statusBarHeight = (page && !page.backgroundSpanUnderStatusBar && !this.parent) ? uiUtils.ios.getStatusBarHeight() : 0; diff --git a/ui/page/page.ios.ts b/ui/page/page.ios.ts index 6d427603d..ced099440 100644 --- a/ui/page/page.ios.ts +++ b/ui/page/page.ios.ts @@ -96,6 +96,9 @@ class UIViewControllerImpl extends UIViewController { trace.write(owner + " viewWillAppear", trace.categories.Navigation); owner._enableLoadedEvents = true; + //https://github.com/NativeScript/NativeScript/issues/1201 + owner._viewWillDisappear = false; + // In iOS we intentionally delay the raising of the 'loaded' event so both platforms behave identically. // The loaded event must be raised AFTER the page is part of the windows hierarchy and // frame.topmost().currentPage is set to the page instance. @@ -108,6 +111,18 @@ class UIViewControllerImpl extends UIViewController { owner._enableLoadedEvents = false; } + public viewWillDisappear() { + let owner = this._owner.get(); + if (!owner) { + return; + } + + trace.write(owner + " viewWillDisappear", trace.categories.Navigation); + + //https://github.com/NativeScript/NativeScript/issues/1201 + owner._viewWillDisappear = true; + } + public viewDidDisappear() { let owner = this._owner.get(); if (!owner) { @@ -128,9 +143,10 @@ class UIViewControllerImpl extends UIViewController { export class Page extends pageCommon.Page { private _ios: UIViewController; public _enableLoadedEvents: boolean; - public _isModal: boolean = false; - public _UIModalPresentationFormSheet: boolean = false; - public _delayLoadedEvent; + public _isModal: boolean; + public _UIModalPresentationFormSheet: boolean; + public _delayLoadedEvent: boolean; + public _viewWillDisappear: boolean; constructor(options?: definition.Options) { super(options);