mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(ios): getVisibleViewController maximum call stack exceeded
This commit is contained in:
@ -96,19 +96,12 @@ export namespace iOSNativeHelper {
|
||||
}
|
||||
|
||||
export function getVisibleViewController(rootViewController: UIViewController): UIViewController {
|
||||
if (rootViewController.presentedViewController) {
|
||||
return getVisibleViewController(rootViewController.presentedViewController);
|
||||
}
|
||||
let viewController = rootViewController;
|
||||
|
||||
if (rootViewController.isKindOfClass(UINavigationController.class())) {
|
||||
return getVisibleViewController((<UINavigationController>rootViewController).visibleViewController);
|
||||
while (viewController && viewController.presentedViewController) {
|
||||
viewController = viewController.presentedViewController;
|
||||
}
|
||||
|
||||
if (rootViewController.isKindOfClass(UITabBarController.class())) {
|
||||
return getVisibleViewController(<UITabBarController>rootViewController);
|
||||
}
|
||||
|
||||
return rootViewController;
|
||||
return viewController;
|
||||
}
|
||||
|
||||
export function applyRotateTransform(transform: CATransform3D, x: number, y: number, z: number): CATransform3D {
|
||||
@ -125,33 +118,33 @@ export namespace iOSNativeHelper {
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
|
||||
export function createUIDocumentInteractionControllerDelegate(): NSObject {
|
||||
@NativeClass
|
||||
class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate {
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
export function createUIDocumentInteractionControllerDelegate(): NSObject {
|
||||
@NativeClass
|
||||
class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate {
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
|
||||
public getViewController(): UIViewController {
|
||||
const app = UIApplication.sharedApplication;
|
||||
public getViewController(): UIViewController {
|
||||
const app = UIApplication.sharedApplication;
|
||||
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController();
|
||||
}
|
||||
public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController();
|
||||
}
|
||||
|
||||
public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController().view;
|
||||
}
|
||||
public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController().view;
|
||||
}
|
||||
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
}
|
||||
return new UIDocumentInteractionControllerDelegateImpl();
|
||||
}
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
}
|
||||
return new UIDocumentInteractionControllerDelegateImpl();
|
||||
}
|
||||
|
||||
export function isRealDevice() {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user