Skip to content

Commit

Permalink
Fixes for iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Alden committed Sep 26, 2019
1 parent 5dd23b8 commit 1223e66
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/ios/CDVThemeableBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,27 @@ - (void)show:(CDVInvokedUrlCommand*)command withAnimation:(BOOL)animated
initWithRootViewController:self.themeableBrowserViewController];
nav.orientationDelegate = self.themeableBrowserViewController;
nav.navigationBarHidden = YES;
if (@available(iOS 13.0, *)) {
nav.modalInPresentation = true;
nav.modalPresentationStyle = UIModalPresentationOverFullScreen;
}

__weak CDVThemeableBrowser* weakSelf = self;

// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
if (self.themeableBrowserViewController != nil) {
CGRect frame = [[UIScreen mainScreen] bounds];
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
__strong __typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf->tmpWindow) {
CGRect frame = [[UIScreen mainScreen] bounds];
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
}

UIViewController *tmpController = [[UIViewController alloc] init];
[tmpWindow setRootViewController:tmpController];
[tmpWindow setWindowLevel:UIWindowLevelNormal];
[strongSelf->tmpWindow setRootViewController:tmpController];


[tmpWindow makeKeyAndVisible];
[strongSelf->tmpWindow makeKeyAndVisible];
[tmpController presentViewController:nav animated:YES completion:nil];
}
});
Expand Down Expand Up @@ -626,6 +637,11 @@ - (void)browserExit
// Don't recycle the ViewController since it may be consuming a lot of memory.
// Also - this is required for the PDF/User-Agent bug work-around.
self.themeableBrowserViewController = nil;

// Set tmpWindow to hidden to make main webview responsive to touch again
// Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
self->tmpWindow.hidden = YES;

self.callbackId = nil;
self.callbackIdPattern = nil;

Expand Down

0 comments on commit 1223e66

Please sign in to comment.