cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject git commit: CB-5431 - Status Bar Plugin blanks view on call overlaysWebView(false) in landscape orientation
Date Tue, 19 Nov 2013 01:21:17 GMT
Updated Branches:
  refs/heads/master e1b942e60 -> 3384f32c3


CB-5431 - Status Bar Plugin blanks view on call overlaysWebView(false) in landscape orientation

Note that this has been tested and works on iPad only, and Universal. On iPhone only while
on iPad, there is a black area where the status bar is (bug in statusBarBackgroundView positioning)


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/3384f32c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/3384f32c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/3384f32c

Branch: refs/heads/master
Commit: 3384f32c3208d5a6d0debc67e07de650fca7dec4
Parents: e1b942e
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Nov 18 17:20:22 2013 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Nov 18 17:20:37 2013 -0800

----------------------------------------------------------------------
 statusbar/src/ios/CDVStatusBar.m | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/3384f32c/statusbar/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.m b/statusbar/src/ios/CDVStatusBar.m
index 25c70f8..461df31 100644
--- a/statusbar/src/ios/CDVStatusBar.m
+++ b/statusbar/src/ios/CDVStatusBar.m
@@ -100,11 +100,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
     
     _statusBarOverlaysWebView = YES; // default
     
-    CGRect frame = [[UIApplication sharedApplication] statusBarFrame];
-    
-    _statusBarBackgroundView = [[UIView alloc] initWithFrame:frame];
-    _statusBarBackgroundView.backgroundColor = [UIColor blackColor];
-    _statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
+    [self initializeStatusBarBackgroundView];
     
     [self styleLightContent:nil]; // match default backgroundColor of #000000
     
@@ -127,6 +123,19 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
     [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;",
[UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]];
 }
 
+- (void) initializeStatusBarBackgroundView 
+{
+    CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
+    if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
+        // swap width and height. set origin to zero
+        statusBarFrame = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.size.width);
+    }
+
+    _statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
+    _statusBarBackgroundView.backgroundColor = [UIColor blackColor];
+    _statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
+}
+
 - (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
 {
     // we only care about the latest iOS version or a change in setting
@@ -144,10 +153,20 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
     } else {
 
         CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
-        bounds.origin.y = statusBarFrame.size.height;
-        bounds.size.height -= statusBarFrame.size.height;
+
+        [self initializeStatusBarBackgroundView];
+
+        CGRect frame = self.webView.frame;
+
+        if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
+            frame.origin.y = statusBarFrame.size.width;
+            frame.size.height -= statusBarFrame.size.width;
+        } else {
+            frame.origin.y = statusBarFrame.size.height;
+            frame.size.height -= statusBarFrame.size.height;
+        }
         
-        self.webView.frame = bounds;
+        self.webView.frame = frame;
         [self.webView.superview addSubview:_statusBarBackgroundView];
     }
     


Mime
View raw message