CB-4930 - iOS - InAppBrowser should take into account the status bar

This commit is contained in:
Shazron Abdullah 2013-10-15 15:00:09 -07:00
parent ce7a796cb0
commit c7972b6cff

View File

@ -32,6 +32,11 @@
#pragma mark CDVInAppBrowser
@interface CDVInAppBrowser () {
UIStatusBarStyle _previousStatusBarStyle;
}
@end
@implementation CDVInAppBrowser
- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
@ -115,6 +120,7 @@
}
}
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
[self.inAppBrowserViewController showLocationBar:browserOptions.location];
@ -155,8 +161,13 @@
}
if (! browserOptions.hidden) {
UINavigationController* nav = [[UINavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
nav.navigationBarHidden = YES;
if (self.viewController.modalViewController != self.inAppBrowserViewController) {
[self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
[self.viewController presentModalViewController:nav animated:YES];
}
}
[self.inAppBrowserViewController navigateTo:url];
@ -166,7 +177,13 @@
{
if ([self.inAppBrowserViewController isViewLoaded] && self.inAppBrowserViewController.view.window)
return;
[self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
UINavigationController* nav = [[UINavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
nav.navigationBarHidden = YES;
[self.viewController presentModalViewController:nav animated:YES];
}
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
@ -362,6 +379,10 @@
// 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.inAppBrowserViewController = nil;
if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
}
}
@end
@ -633,6 +654,11 @@
[super viewDidUnload];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
- (void)close
{
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
@ -675,6 +701,15 @@
[self.webView goForward];
}
- (void)viewWillAppear:(BOOL)animated
{
if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
}
[super viewWillAppear:animated];
}
#pragma mark UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView*)theWebView