Skip to content

Commit 2c4a917

Browse files
committed
Merge pull request NativeScript#1202 from NativeScript/issue-1201
Fixed Issue NativeScript#1201: iOS: A page that is disappearing with animation af…
2 parents 6d43f4d + e14fdba commit 2c4a917

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

ui/frame/frame.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ export class Frame extends frameCommon.Frame {
206206
}
207207

208208
public measurePage(page: pages.Page): { measuredWidth: number; measuredHeight: number } {
209-
210209
// If background does not span under statusbar - reduce available height.
211210
let heightSpec: number = this._heightMeasureSpec;
212211
if (page && !page.backgroundSpanUnderStatusBar && !this.parent) {
@@ -229,6 +228,11 @@ export class Frame extends frameCommon.Frame {
229228
}
230229

231230
public layoutPage(page: pages.Page): void {
231+
if (page && (<any>page)._viewWillDisappear) {
232+
//https://github.com/NativeScript/NativeScript/issues/1201
233+
return;
234+
}
235+
232236
// If background does not span under statusbar - reduce available height and adjust top offset.
233237
let statusBarHeight = (page && !page.backgroundSpanUnderStatusBar && !this.parent) ? uiUtils.ios.getStatusBarHeight() : 0;
234238

ui/page/page.ios.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class UIViewControllerImpl extends UIViewController {
9696
trace.write(owner + " viewWillAppear", trace.categories.Navigation);
9797
owner._enableLoadedEvents = true;
9898

99+
//https://github.com/NativeScript/NativeScript/issues/1201
100+
owner._viewWillDisappear = false;
101+
99102
// In iOS we intentionally delay the raising of the 'loaded' event so both platforms behave identically.
100103
// The loaded event must be raised AFTER the page is part of the windows hierarchy and
101104
// frame.topmost().currentPage is set to the page instance.
@@ -108,6 +111,18 @@ class UIViewControllerImpl extends UIViewController {
108111
owner._enableLoadedEvents = false;
109112
}
110113

114+
public viewWillDisappear() {
115+
let owner = this._owner.get();
116+
if (!owner) {
117+
return;
118+
}
119+
120+
trace.write(owner + " viewWillDisappear", trace.categories.Navigation);
121+
122+
//https://github.com/NativeScript/NativeScript/issues/1201
123+
owner._viewWillDisappear = true;
124+
}
125+
111126
public viewDidDisappear() {
112127
let owner = this._owner.get();
113128
if (!owner) {
@@ -128,9 +143,10 @@ class UIViewControllerImpl extends UIViewController {
128143
export class Page extends pageCommon.Page {
129144
private _ios: UIViewController;
130145
public _enableLoadedEvents: boolean;
131-
public _isModal: boolean = false;
132-
public _UIModalPresentationFormSheet: boolean = false;
133-
public _delayLoadedEvent;
146+
public _isModal: boolean;
147+
public _UIModalPresentationFormSheet: boolean;
148+
public _delayLoadedEvent: boolean;
149+
public _viewWillDisappear: boolean;
134150

135151
constructor(options?: definition.Options) {
136152
super(options);

0 commit comments

Comments
 (0)