mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Merge pull request #961 from NativeScript/issue-779
Fixed #779: frame.topmost().currentPage is not the same instance as t…
This commit is contained in:
@ -309,6 +309,14 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
|
||||
frame._currentEntry = newEntry;
|
||||
|
||||
var newPage = newEntry.resolvedPage;
|
||||
|
||||
// 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.
|
||||
// https://github.com/NativeScript/NativeScript/issues/779
|
||||
(<any>newPage)._delayLoadedEvent = false;
|
||||
newPage._emit(view.View.loadedEvent);
|
||||
|
||||
frame._updateActionBar(newPage);
|
||||
|
||||
// notify the page
|
||||
|
@ -6,6 +6,7 @@ import uiUtils = require("ui/utils");
|
||||
import utils = require("utils/utils");
|
||||
import {device} from "platform";
|
||||
import {DeviceType} from "ui/enums";
|
||||
import observable = require("data/observable");
|
||||
|
||||
global.moduleMerge(pageCommon, exports);
|
||||
|
||||
@ -94,6 +95,15 @@ class UIViewControllerImpl extends UIViewController {
|
||||
public viewWillAppear() {
|
||||
trace.write(this._owner + " viewWillAppear", trace.categories.Navigation);
|
||||
this._owner._enableLoadedEvents = true;
|
||||
|
||||
// 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.
|
||||
// https://github.com/NativeScript/NativeScript/issues/779
|
||||
if (!this._owner._isModal) {
|
||||
this._owner._delayLoadedEvent = true;
|
||||
}
|
||||
|
||||
this._owner.onLoaded();
|
||||
this._owner._enableLoadedEvents = false;
|
||||
}
|
||||
@ -111,6 +121,7 @@ export class Page extends pageCommon.Page {
|
||||
public _enableLoadedEvents: boolean;
|
||||
public _isModal: boolean = false;
|
||||
public _UIModalPresentationFormSheet: boolean = false;
|
||||
public _delayLoadedEvent;
|
||||
|
||||
constructor(options?: definition.Options) {
|
||||
super(options);
|
||||
@ -137,6 +148,18 @@ export class Page extends pageCommon.Page {
|
||||
}
|
||||
}
|
||||
|
||||
public notify<T extends observable.EventData>(data: T) {
|
||||
// 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.
|
||||
// https://github.com/NativeScript/NativeScript/issues/779
|
||||
if (data.eventName === View.loadedEvent && this._delayLoadedEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.notify(data);
|
||||
}
|
||||
|
||||
public onUnloaded() {
|
||||
// loaded/unloaded events are handled in page viewWillAppear/viewDidDisappear
|
||||
if (this._enableLoadedEvents) {
|
||||
|
Reference in New Issue
Block a user