From 82d496ae5cdbbc7f46ce20c77d6ad7bcbe2fb207 Mon Sep 17 00:00:00 2001 From: Niklas Merz Date: Fri, 20 Sep 2019 13:43:57 +0200 Subject: [PATCH] Use tmpWindow and hide on close --- src/ios/CDVWKInAppBrowser.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 02aa80d..fdc88dc 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -80,6 +80,11 @@ static CDVWKInAppBrowser* instance = nil; NSLog(@"IAB.close() called but it was already closed."); return; } + + // Set tmpWindow to hidden to make main webview responsive to touch again + // https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow + self->tmpWindow.hidden = YES; + // Things are cleaned up in browserExit. [self.inAppBrowserViewController close]; } @@ -314,17 +319,18 @@ static CDVWKInAppBrowser* instance = nil; dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.inAppBrowserViewController != nil) { float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; - if (!self->tmpWindow) { + __strong __typeof(weakSelf) strongSelf = weakSelf; + if (!strongSelf->tmpWindow) { CGRect frame = [[UIScreen mainScreen] bounds]; if(initHidden && osVersion < 11){ frame.origin.x = -10000; } - self->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; + strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; } UIViewController *tmpController = [[UIViewController alloc] init]; - [self->tmpWindow setRootViewController:tmpController]; - [self->tmpWindow setWindowLevel:UIWindowLevelNormal]; + [strongSelf->tmpWindow setRootViewController:tmpController]; + [strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal]; if(!initHidden || osVersion < 11){ [self->tmpWindow makeKeyAndVisible];