@@ -80,6 +80,7 @@ - (void)close:(CDVInvokedUrlCommand*)command
80
80
NSLog (@" IAB.close() called but it was already closed." );
81
81
return ;
82
82
}
83
+
83
84
// Things are cleaned up in browserExit.
84
85
[self .inAppBrowserViewController close ];
85
86
}
@@ -275,7 +276,9 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
275
276
_waitForBeforeload = ![_beforeload isEqualToString: @" " ];
276
277
277
278
[self .inAppBrowserViewController navigateTo: url];
278
- [self show: nil withNoAnimate: browserOptions.hidden];
279
+ if (!browserOptions.hidden ) {
280
+ [self show: nil withNoAnimate: browserOptions.hidden];
281
+ }
279
282
}
280
283
281
284
- (void )show : (CDVInvokedUrlCommand*)command {
@@ -314,19 +317,21 @@ - (void)show:(CDVInvokedUrlCommand*)command withNoAnimate:(BOOL)noAnimate
314
317
dispatch_async (dispatch_get_main_queue (), ^{
315
318
if (weakSelf.inAppBrowserViewController != nil ) {
316
319
float osVersion = [[[UIDevice currentDevice ] systemVersion ] floatValue ];
317
- CGRect frame = [[UIScreen mainScreen ] bounds ];
318
- if (initHidden && osVersion < 11 ){
319
- frame.origin .x = -10000 ;
320
+ __strong __typeof (weakSelf) strongSelf = weakSelf;
321
+ if (!strongSelf->tmpWindow ) {
322
+ CGRect frame = [[UIScreen mainScreen ] bounds ];
323
+ if (initHidden && osVersion < 11 ){
324
+ frame.origin .x = -10000 ;
325
+ }
326
+ strongSelf->tmpWindow = [[UIWindow alloc ] initWithFrame: frame];
320
327
}
321
-
322
- UIWindow *tmpWindow = [[UIWindow alloc ] initWithFrame: frame];
323
328
UIViewController *tmpController = [[UIViewController alloc ] init ];
324
-
325
- [tmpWindow setRootViewController: tmpController];
326
- [tmpWindow setWindowLevel: UIWindowLevelNormal];
327
-
329
+
330
+ [strongSelf-> tmpWindow setRootViewController: tmpController];
331
+ [strongSelf-> tmpWindow setWindowLevel: UIWindowLevelNormal];
332
+
328
333
if (!initHidden || osVersion < 11 ){
329
- [ tmpWindow makeKeyAndVisible ];
334
+ [ self -> tmpWindow makeKeyAndVisible ];
330
335
}
331
336
[tmpController presentViewController: nav animated: !noAnimate completion: nil ];
332
337
}
@@ -335,6 +340,10 @@ - (void)show:(CDVInvokedUrlCommand*)command withNoAnimate:(BOOL)noAnimate
335
340
336
341
- (void )hide : (CDVInvokedUrlCommand*)command
337
342
{
343
+ // Set tmpWindow to hidden to make main webview responsive to touch again
344
+ // https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
345
+ self->tmpWindow .hidden = YES ;
346
+
338
347
if (self.inAppBrowserViewController == nil ) {
339
348
NSLog (@" Tried to hide IAB after it was closed." );
340
349
return ;
@@ -690,6 +699,10 @@ - (void)browserExit
690
699
// Set navigationDelegate to nil to ensure no callbacks are received from it.
691
700
self.inAppBrowserViewController .navigationDelegate = nil ;
692
701
self.inAppBrowserViewController = nil ;
702
+
703
+ // Set tmpWindow to hidden to make main webview responsive to touch again
704
+ // Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
705
+ self->tmpWindow .hidden = YES ;
693
706
694
707
if (IsAtLeastiOSVersion (@" 7.0" )) {
695
708
if (_previousStatusBarStyle != -1 ) {
@@ -786,7 +799,7 @@ - (void)createViews
786
799
787
800
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
788
801
if (@available (iOS 11.0 , *)) {
789
- [self .webView.scrollView setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];
802
+ [self .webView.scrollView setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];
790
803
}
791
804
#endif
792
805
0 commit comments