Merge pull request #2896 from NativeScript/viewDidLoad-fix

code fixed to work in viewDidLoad
This commit is contained in:
Vladimir Enchev
2016-10-14 11:06:30 +03:00
committed by GitHub

View File

@ -283,11 +283,16 @@ typedExports.start = function (entry?: NavigationEntry) {
let rootView = createRootView(); let rootView = createRootView();
if(rootView) { if(rootView) {
// Attach to the existing iOS app // Attach to the existing iOS app
let rootController = iosApp.nativeApp.keyWindow.rootViewController; var window = iosApp.nativeApp.keyWindow || (iosApp.nativeApp.windows.count > 0 && iosApp.nativeApp.windows[0]);
if(window) {
var rootController = window.rootViewController;
if(rootController) {
rootController.presentViewControllerAnimatedCompletion(rootView.ios.controller, utils.ios.MajorVersion >= 7, null); rootController.presentViewControllerAnimatedCompletion(rootView.ios.controller, utils.ios.MajorVersion >= 7, null);
uiUtils.ios._layoutRootView(rootView, utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds); uiUtils.ios._layoutRootView(rootView, utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds);
} }
} }
}
}
} else { } else {
throw new Error("iOS Application already started!"); throw new Error("iOS Application already started!");