mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
fix-next: drawer plugin viewcontroller init (#6379)
This commit is contained in:
@ -227,6 +227,8 @@ class IOSApplication implements IOSApplicationDefinition {
|
|||||||
this._rootView._onRootViewReset();
|
this._rootView._onRootViewReset();
|
||||||
}
|
}
|
||||||
const rootView = createRootView(view);
|
const rootView = createRootView(view);
|
||||||
|
const controller = getViewController(rootView);
|
||||||
|
|
||||||
this._rootView = rootView;
|
this._rootView = rootView;
|
||||||
|
|
||||||
if (createRootFrame.value) {
|
if (createRootFrame.value) {
|
||||||
@ -236,7 +238,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
|||||||
// setup view as styleScopeHost
|
// setup view as styleScopeHost
|
||||||
rootView._setupAsRootView({});
|
rootView._setupAsRootView({});
|
||||||
}
|
}
|
||||||
const controller = getViewController(rootView);
|
setViewControllerView(rootView);
|
||||||
const haveController = this._window.rootViewController !== null;
|
const haveController = this._window.rootViewController !== null;
|
||||||
this._window.rootViewController = controller;
|
this._window.rootViewController = controller;
|
||||||
if (!haveController) {
|
if (!haveController) {
|
||||||
@ -339,18 +341,27 @@ function getViewController(view: View): UIViewController {
|
|||||||
if (viewController instanceof UIViewController) {
|
if (viewController instanceof UIViewController) {
|
||||||
return viewController;
|
return viewController;
|
||||||
} else {
|
} else {
|
||||||
const nativeView = view.ios || view.nativeViewProtected;
|
// We set UILayoutViewController dynamically to the root view if it doesn't have a view controller
|
||||||
if (nativeView instanceof UIView) {
|
// At the moment the root view doesn't have its native view created. We set it in the setViewControllerView func
|
||||||
viewController = iosView.UILayoutViewController.initWithOwner(new WeakRef(view)) as UIViewController;
|
viewController = iosView.UILayoutViewController.initWithOwner(new WeakRef(view)) as UIViewController;
|
||||||
viewController.view.addSubview(nativeView);
|
|
||||||
view.viewController = viewController;
|
view.viewController = viewController;
|
||||||
return viewController;
|
return viewController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setViewControllerView(view: View): void {
|
||||||
|
const viewController: UIViewController = view.viewController || view.ios;
|
||||||
|
const nativeView = view.ios || view.nativeViewProtected;
|
||||||
|
|
||||||
|
if (!nativeView || !viewController) {
|
||||||
throw new Error("Root should be either UIViewController or UIView");
|
throw new Error("Root should be either UIViewController or UIView");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (viewController instanceof iosView.UILayoutViewController) {
|
||||||
|
viewController.view.addSubview(nativeView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
global.__onLiveSync = function () {
|
global.__onLiveSync = function () {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user