From 640075e0c4d0dfd1109642e556a8e83ad5a6dcf2 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Mon, 4 Dec 2017 22:11:09 +0100 Subject: [PATCH] use helper method to get topmost view controller (#80) --- SafariViewManager.m | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SafariViewManager.m b/SafariViewManager.m index 0bb7c0c..e26be0c 100644 --- a/SafariViewManager.m +++ b/SafariViewManager.m @@ -72,13 +72,9 @@ - (void)stopObserving self.safariView.modalPresentationStyle = UIModalPresentationOverFullScreen; } - UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - - // Cycle through view controllers to get the view closest to the foreground - while (ctrl.presentedViewController && !ctrl.isBeingDismissed) { - ctrl = ctrl.presentedViewController; - } - + // get the view controller closest to the foreground + UIViewController *ctrl = RCTPresentedViewController(); + // Display the Safari View [ctrl presentViewController:self.safariView animated:YES completion:nil];