Skip to content

Commit b783328

Browse files
Dave Aldendpa99c
authored andcommitted
Fixes for iOS 13
1 parent 5dd23b8 commit b783328

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/ios/CDVThemeableBrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
@class CDVThemeableBrowserViewController;
6464

6565
@interface CDVThemeableBrowser : CDVPlugin {
66+
UIWindow * tmpWindow;
6667
BOOL _injectedIframeBridge;
6768
}
6869

src/ios/CDVThemeableBrowser.m

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,27 @@ - (void)show:(CDVInvokedUrlCommand*)command withAnimation:(BOOL)animated
329329
initWithRootViewController:self.themeableBrowserViewController];
330330
nav.orientationDelegate = self.themeableBrowserViewController;
331331
nav.navigationBarHidden = YES;
332+
if (@available(iOS 13.0, *)) {
333+
nav.modalInPresentation = true;
334+
nav.modalPresentationStyle = UIModalPresentationOverFullScreen;
335+
}
336+
337+
__weak CDVThemeableBrowser* weakSelf = self;
338+
332339
// Run later to avoid the "took a long time" log message.
333340
dispatch_async(dispatch_get_main_queue(), ^{
334341
if (self.themeableBrowserViewController != nil) {
335-
CGRect frame = [[UIScreen mainScreen] bounds];
336-
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
342+
__strong __typeof(weakSelf) strongSelf = weakSelf;
343+
if (!strongSelf->tmpWindow) {
344+
CGRect frame = [[UIScreen mainScreen] bounds];
345+
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
346+
}
347+
337348
UIViewController *tmpController = [[UIViewController alloc] init];
338-
[tmpWindow setRootViewController:tmpController];
339-
[tmpWindow setWindowLevel:UIWindowLevelNormal];
349+
[strongSelf->tmpWindow setRootViewController:tmpController];
350+
340351

341-
[tmpWindow makeKeyAndVisible];
352+
[strongSelf->tmpWindow makeKeyAndVisible];
342353
[tmpController presentViewController:nav animated:YES completion:nil];
343354
}
344355
});
@@ -626,6 +637,11 @@ - (void)browserExit
626637
// Don't recycle the ViewController since it may be consuming a lot of memory.
627638
// Also - this is required for the PDF/User-Agent bug work-around.
628639
self.themeableBrowserViewController = nil;
640+
641+
// Set tmpWindow to hidden to make main webview responsive to touch again
642+
// Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
643+
self->tmpWindow.hidden = YES;
644+
629645
self.callbackId = nil;
630646
self.callbackIdPattern = nil;
631647

0 commit comments

Comments
 (0)