mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
feat(ios): Utils.getRootViewController
This commit is contained in:
5
packages/core/utils/native-helper.d.ts
vendored
5
packages/core/utils/native-helper.d.ts
vendored
@ -132,6 +132,11 @@ export namespace iOSNativeHelper {
|
|||||||
export function nsArrayToJSArray<T>(a: NSArray<T>): T[];
|
export function nsArrayToJSArray<T>(a: NSArray<T>): T[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the root UIViewController of the app
|
||||||
|
*/
|
||||||
|
export function getRootViewController(): any; /* UIViewController */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data serialize and deserialize helpers
|
* Data serialize and deserialize helpers
|
||||||
*/
|
*/
|
||||||
|
@ -136,6 +136,16 @@ export namespace iOSNativeHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRootViewController(): UIViewController {
|
||||||
|
const app = UIApplication.sharedApplication;
|
||||||
|
const win = app.keyWindow || (app.windows && app.windows.count > 0 && app.windows.objectAtIndex(0));
|
||||||
|
let vc = win.rootViewController;
|
||||||
|
while (vc && vc.presentedViewController) {
|
||||||
|
vc = vc.presentedViewController;
|
||||||
|
}
|
||||||
|
return vc;
|
||||||
|
}
|
||||||
|
|
||||||
export function isLandscape(): boolean {
|
export function isLandscape(): boolean {
|
||||||
console.log('utils.ios.isLandscape() is deprecated; use application.orientation instead');
|
console.log('utils.ios.isLandscape() is deprecated; use application.orientation instead');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user