Use tmpWindow and hide on close

This commit is contained in:
Niklas Merz 2019-09-20 13:43:57 +02:00
parent 8805f5d46a
commit 82d496ae5c

View File

@ -80,6 +80,11 @@ static CDVWKInAppBrowser* instance = nil;
NSLog(@"IAB.close() called but it was already closed."); NSLog(@"IAB.close() called but it was already closed.");
return; 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. // Things are cleaned up in browserExit.
[self.inAppBrowserViewController close]; [self.inAppBrowserViewController close];
} }
@ -314,17 +319,18 @@ static CDVWKInAppBrowser* instance = nil;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.inAppBrowserViewController != nil) { if (weakSelf.inAppBrowserViewController != nil) {
float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (!self->tmpWindow) { __strong __typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf->tmpWindow) {
CGRect frame = [[UIScreen mainScreen] bounds]; CGRect frame = [[UIScreen mainScreen] bounds];
if(initHidden && osVersion < 11){ if(initHidden && osVersion < 11){
frame.origin.x = -10000; frame.origin.x = -10000;
} }
self->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
} }
UIViewController *tmpController = [[UIViewController alloc] init]; UIViewController *tmpController = [[UIViewController alloc] init];
[self->tmpWindow setRootViewController:tmpController]; [strongSelf->tmpWindow setRootViewController:tmpController];
[self->tmpWindow setWindowLevel:UIWindowLevelNormal]; [strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal];
if(!initHidden || osVersion < 11){ if(!initHidden || osVersion < 11){
[self->tmpWindow makeKeyAndVisible]; [self->tmpWindow makeKeyAndVisible];