You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/12/13 15:18:12 UTC

[2/3] git commit: CB-5595 Fixed the positioning and autoresizing for certain rotation scenarios.

CB-5595 Fixed the positioning and autoresizing for certain rotation scenarios.

The autoresizing masks are applied conditonally based on the
browserOptions.toolbarposition flag to ensure that the toolbar is in
its correct place. Also added a utility function to query the
necessary offset for the status bar: the function takes care of the iOS
version and orientation caused differences without hardcoding the value
as 20 pixels.


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/4aeaf81e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/4aeaf81e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/4aeaf81e

Branch: refs/heads/dev
Commit: 4aeaf81e1eb3baf474270c2830dacc800792c487
Parents: 20611ef
Author: Peter Somogyvari <pe...@mippin.com>
Authored: Mon Nov 18 17:14:19 2013 +0000
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Dec 13 09:17:11 2013 -0500

----------------------------------------------------------------------
 src/ios/CDVInAppBrowser.m | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/4aeaf81e/src/ios/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index 8b5e14d..153ba58 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -463,7 +463,7 @@
     self.toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
     self.toolbar.alpha = 1.000;
     self.toolbar.autoresizesSubviews = YES;
-    self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
+    self.toolbar.autoresizingMask = toolbarIsAtBottom ? (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin) : UIViewAutoresizingFlexibleWidth;
     self.toolbar.barStyle = UIBarStyleBlackOpaque;
     self.toolbar.clearsContextBeforeDrawing = NO;
     self.toolbar.clipsToBounds = NO;
@@ -719,12 +719,21 @@
     [super viewWillAppear:animated];
 }
 
+//
+// On iOS 7 the status bar is part of the view's dimensions, therefore it's height has to be taken into account.
+// The height of it could be hardcoded as 20 pixels, but that would assume that the upcoming releases of iOS won't
+// change that value.
+//
+- (float) getStatusBarOffset {
+    CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
+    float statusBarOffset = IsAtLeastiOSVersion(@"7.0") ? MIN(statusBarFrame.size.width, statusBarFrame.size.height) : 0.0;
+    return statusBarOffset;
+}
+
 - (void) rePositionViews {
     if ([_browserOptions.toolbarbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop]) {
         [self.webView setFrame:CGRectMake(self.webView.frame.origin.x, TOOLBAR_HEIGHT, self.webView.frame.size.width, self.webView.frame.size.height)];
-        
-        float offsetForStatusBar = IsAtLeastiOSVersion(@"7.0") ? 21.0 : 0.0;
-        [self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, self.toolbar.frame.origin.y + offsetForStatusBar, self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
+        [self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, [self getStatusBarOffset], self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
     }
 }