@@ -239,8 +239,10 @@ - (void)show:(CDVInvokedUrlCommand*)command
239239 // Run later to avoid the "took a long time" log message.
240240 dispatch_async (dispatch_get_main_queue (), ^{
241241 if (weakSelf.inAppBrowserViewController != nil ) {
242- CGRect frame = [[UIScreen mainScreen ] bounds ];
243- UIWindow *tmpWindow = [[UIWindow alloc ] initWithFrame: frame];
242+ if (!tmpWindow) {
243+ CGRect frame = [[UIScreen mainScreen ] bounds ];
244+ tmpWindow = [[UIWindow alloc ] initWithFrame: frame];
245+ }
244246 UIViewController *tmpController = [[UIViewController alloc ] init ];
245247 [tmpWindow setRootViewController: tmpController];
246248 [tmpWindow setWindowLevel: UIWindowLevelNormal];
@@ -270,7 +272,9 @@ - (void)hide:(CDVInvokedUrlCommand*)command
270272 dispatch_async (dispatch_get_main_queue (), ^{
271273 if (self.inAppBrowserViewController != nil ) {
272274 _previousStatusBarStyle = -1 ;
273- [self .inAppBrowserViewController.presentingViewController dismissViewControllerAnimated: YES completion: nil ];
275+ [self .inAppBrowserViewController.presentingViewController dismissViewControllerAnimated: YES completion: ^{
276+ [[[[UIApplication sharedApplication ] delegate ] window ] makeKeyAndVisible ];
277+ }];
274278 }
275279 });
276280}
@@ -835,9 +839,13 @@ - (void)close
835839 // Run later to avoid the "took a long time" log message.
836840 dispatch_async (dispatch_get_main_queue (), ^{
837841 if ([weakSelf respondsToSelector: @selector (presentingViewController )]) {
838- [[weakSelf presentingViewController ] dismissViewControllerAnimated: YES completion: nil ];
842+ [[weakSelf presentingViewController ] dismissViewControllerAnimated: YES completion: ^{
843+ [[[[UIApplication sharedApplication ] delegate ] window ] makeKeyAndVisible ];
844+ }];
839845 } else {
840- [[weakSelf parentViewController ] dismissViewControllerAnimated: YES completion: nil ];
846+ [[weakSelf parentViewController ] dismissViewControllerAnimated: YES completion: ^{
847+ [[[[UIApplication sharedApplication ] delegate ] window ] makeKeyAndVisible ];
848+ }];
841849 }
842850 });
843851}
0 commit comments