You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/10/28 23:13:06 UTC
[08/12] git commit: CB-4930 - iOS - InAppBrowser should take into
account the status bar
CB-4930 - iOS - InAppBrowser should take into account the status bar
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/c7972b6c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/c7972b6c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/c7972b6c
Branch: refs/heads/master
Commit: c7972b6cffcedae7a9bbbeb66875a5d2fb37ce29
Parents: ce7a796
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Oct 15 15:00:09 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Oct 15 15:00:09 2013 -0700
----------------------------------------------------------------------
src/ios/CDVInAppBrowser.m | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/c7972b6c/src/ios/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index 4170dd2..5711e76 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -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
@@ -632,6 +653,11 @@
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
[super viewDidUnload];
}
+
+- (UIStatusBarStyle)preferredStatusBarStyle
+{
+ return UIStatusBarStyleDefault;
+}
- (void)close
{
@@ -674,6 +700,15 @@
{
[self.webView goForward];
}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ if (IsAtLeastiOSVersion(@"7.0")) {
+ [[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
+ }
+
+ [super viewWillAppear:animated];
+}
#pragma mark UIWebViewDelegate