fix(iOS): changed the way the top view controller is obtained. (#1592)

Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
This commit is contained in:
cristianoccazinsp 2020-08-25 20:13:00 -03:00 committed by GitHub
parent db529e265f
commit 2cb2113c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 32 deletions

View File

@ -880,40 +880,9 @@ static NSDictionary* customCertificatesForHost;
* topViewController
*/
-(UIViewController *)topViewController{
UIViewController *controller = [self topViewControllerWithRootViewController:[self getCurrentWindow].rootViewController];
return controller;
return RCTPresentedViewController();
}
/**
* topViewControllerWithRootViewController
*/
-(UIViewController *)topViewControllerWithRootViewController:(UIViewController *)viewController{
if (viewController==nil) return nil;
if (viewController.presentedViewController!=nil && viewController.presentedViewController.isBeingPresented) {
return [self topViewControllerWithRootViewController:viewController.presentedViewController];
} else if ([viewController isKindOfClass:[UITabBarController class]]){
return [self topViewControllerWithRootViewController:[(UITabBarController *)viewController selectedViewController]];
} else if ([viewController isKindOfClass:[UINavigationController class]]){
return [self topViewControllerWithRootViewController:[(UINavigationController *)viewController visibleViewController]];
} else {
return viewController;
}
}
/**
* getCurrentWindow
*/
-(UIWindow *)getCurrentWindow{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
if (window.windowLevel!=UIWindowLevelNormal) {
for (UIWindow *wid in [UIApplication sharedApplication].windows) {
if (window.windowLevel==UIWindowLevelNormal) {
window = wid;
break;
}
}
}
return window;
}
#endif // !TARGET_OS_OSX
/**