From b8e87a8b1d7f59d4239a161dd261fcadb12dabb0 Mon Sep 17 00:00:00 2001 From: zher52 Date: Thu, 17 Sep 2020 12:29:39 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E8=A2=AB=E9=81=AE=E6=8C=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ios/CDVWKInAppBrowser.m | 46 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index c7c8bf3..cb1ec50 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -35,7 +35,7 @@ #define IAB_BRIDGE_NAME @"cordova_iab" #define TOOLBAR_HEIGHT 44.0 -#define STATUSBAR_HEIGHT 20.0 +#define STATUSBAR_HEIGHT 0 #define LOCATIONBAR_HEIGHT 21.0 #define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT)) @@ -74,7 +74,11 @@ static CDVWKInAppBrowser* instance = nil; NSLog(@"IAB.close() called but it was already closed."); return; } - + UIView *lastView; + for(UIView *subview in [self.viewController.view subviews]) { + lastView = subview; + } + [lastView removeFromSuperview]; // Things are cleaned up in browserExit. [self.inAppBrowserViewController close]; } @@ -297,24 +301,26 @@ static CDVWKInAppBrowser* instance = nil; // Run later to avoid the "took a long time" log message. dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.inAppBrowserViewController != nil) { - float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; - __strong __typeof(weakSelf) strongSelf = weakSelf; - if (!strongSelf->tmpWindow) { - CGRect frame = [[UIScreen mainScreen] bounds]; - if(initHidden && osVersion < 11){ - frame.origin.x = -10000; - } - strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; - } - UIViewController *tmpController = [[UIViewController alloc] init]; - - [strongSelf->tmpWindow setRootViewController:tmpController]; - [strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal]; - - if(!initHidden || osVersion < 11){ - [self->tmpWindow makeKeyAndVisible]; - } - [tmpController presentViewController:nav animated:!noAnimate completion:nil]; +// float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; +// __strong __typeof(weakSelf) strongSelf = weakSelf; +// if (!strongSelf->tmpWindow) { +// CGRect frame = [[UIScreen mainScreen] bounds]; +// if(initHidden && osVersion < 11){ +// frame.origin.x = -10000; +// } +// strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; +// } +// UIViewController *tmpController = [[UIViewController alloc] init]; +// +// [strongSelf->tmpWindow setRootViewController:tmpController]; +// [strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal]; +// +// if(!initHidden || osVersion < 11){ +// [self->tmpWindow makeKeyAndVisible]; +// } + // [tmpController presentViewController:nav animated:!noAnimate completion:nil]; + self.inAppBrowserViewController.view.frame = CGRectMake(0,STATUSBAR_HEIGHT,self.inAppBrowserViewController.view.frame.size.width,self.inAppBrowserViewController.view.frame.size.height-STATUSBAR_HEIGHT); + [self.viewController.view addSubview:self.inAppBrowserViewController.view]; } }); }