Kaynağa Gözat

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

Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
cristianoccazinsp 4 yıl önce
ebeveyn
işleme
2cb2113c29
No account linked to committer's email address
1 değiştirilmiş dosya ile 1 ekleme ve 32 silme
  1. 1
    32
      apple/RNCWebView.m

+ 1
- 32
apple/RNCWebView.m Dosyayı Görüntüle

@@ -880,40 +880,9 @@ static NSDictionary* customCertificatesForHost;
880 880
  * topViewController
881 881
  */
882 882
 -(UIViewController *)topViewController{
883
-    UIViewController *controller = [self topViewControllerWithRootViewController:[self getCurrentWindow].rootViewController];
884
-    return controller;
883
+    return RCTPresentedViewController();
885 884
 }
886 885
 
887
-/**
888
- * topViewControllerWithRootViewController
889
- */
890
--(UIViewController *)topViewControllerWithRootViewController:(UIViewController *)viewController{
891
-  if (viewController==nil) return nil;
892
-  if (viewController.presentedViewController!=nil && viewController.presentedViewController.isBeingPresented) {
893
-    return [self topViewControllerWithRootViewController:viewController.presentedViewController];
894
-  } else if ([viewController isKindOfClass:[UITabBarController class]]){
895
-    return [self topViewControllerWithRootViewController:[(UITabBarController *)viewController selectedViewController]];
896
-  } else if ([viewController isKindOfClass:[UINavigationController class]]){
897
-    return [self topViewControllerWithRootViewController:[(UINavigationController *)viewController visibleViewController]];
898
-  } else {
899
-    return viewController;
900
-  }
901
-}
902
-/**
903
- * getCurrentWindow
904
- */
905
--(UIWindow *)getCurrentWindow{
906
-  UIWindow *window = [UIApplication sharedApplication].keyWindow;
907
-  if (window.windowLevel!=UIWindowLevelNormal) {
908
-    for (UIWindow *wid in [UIApplication sharedApplication].windows) {
909
-      if (window.windowLevel==UIWindowLevelNormal) {
910
-        window = wid;
911
-        break;
912
-      }
913
-    }
914
-  }
915
-  return window;
916
-}
917 886
 #endif // !TARGET_OS_OSX
918 887
 
919 888
 /**