Fixed Issue #1201: iOS: A page that is disappearing with animation after navigation to another page should not be measured and laid out.

This commit is contained in:
Rossen Hristov
2015-12-04 11:21:53 +02:00
parent 6d43f4dcbc
commit a5afdb1411
2 changed files with 29 additions and 4 deletions

View File

@ -206,7 +206,11 @@ export class Frame extends frameCommon.Frame {
} }
public measurePage(page: pages.Page): { measuredWidth: number; measuredHeight: number } { public measurePage(page: pages.Page): { measuredWidth: number; measuredHeight: number } {
if (page && (<any>page)._viewWillDisappear) {
//https://github.com/NativeScript/NativeScript/issues/1201
return { measuredWidth: undefined, measuredHeight: undefined };
}
// If background does not span under statusbar - reduce available height. // If background does not span under statusbar - reduce available height.
let heightSpec: number = this._heightMeasureSpec; let heightSpec: number = this._heightMeasureSpec;
if (page && !page.backgroundSpanUnderStatusBar && !this.parent) { if (page && !page.backgroundSpanUnderStatusBar && !this.parent) {
@ -229,6 +233,11 @@ export class Frame extends frameCommon.Frame {
} }
public layoutPage(page: pages.Page): void { public layoutPage(page: pages.Page): void {
if (page && (<any>page)._viewWillDisappear) {
//https://github.com/NativeScript/NativeScript/issues/1201
return;
}
// If background does not span under statusbar - reduce available height and adjust top offset. // 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; let statusBarHeight = (page && !page.backgroundSpanUnderStatusBar && !this.parent) ? uiUtils.ios.getStatusBarHeight() : 0;

View File

@ -96,6 +96,9 @@ class UIViewControllerImpl extends UIViewController {
trace.write(owner + " viewWillAppear", trace.categories.Navigation); trace.write(owner + " viewWillAppear", trace.categories.Navigation);
owner._enableLoadedEvents = true; 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. // 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 // 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. // frame.topmost().currentPage is set to the page instance.
@ -108,6 +111,18 @@ class UIViewControllerImpl extends UIViewController {
owner._enableLoadedEvents = false; 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() { public viewDidDisappear() {
let owner = this._owner.get(); let owner = this._owner.get();
if (!owner) { if (!owner) {
@ -128,9 +143,10 @@ class UIViewControllerImpl extends UIViewController {
export class Page extends pageCommon.Page { export class Page extends pageCommon.Page {
private _ios: UIViewController; private _ios: UIViewController;
public _enableLoadedEvents: boolean; public _enableLoadedEvents: boolean;
public _isModal: boolean = false; public _isModal: boolean;
public _UIModalPresentationFormSheet: boolean = false; public _UIModalPresentationFormSheet: boolean;
public _delayLoadedEvent; public _delayLoadedEvent: boolean;
public _viewWillDisappear: boolean;
constructor(options?: definition.Options) { constructor(options?: definition.Options) {
super(options); super(options);