Skip to content

Commit cc11017

Browse files
author
Dave Alden
committed
[iOS] Fix webview height issues
1 parent bbd0b17 commit cc11017

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/ios/CDVThemeableBrowser.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,13 +1456,13 @@ - (void) rePositionViews {
14561456
CGFloat toolbarPadding = _browserOptions.fullscreen ? statusBarOffset : 0.0;
14571457

14581458
if (@available(iOS 11, *)) {
1459-
1459+
// iOS 11+
14601460
CGFloat webviewOffset = _browserOptions.fullscreen ? toolbarPadding + toolbarHeight : toolbarHeight + statusBarOffset;
1461-
1461+
CGFloat webviewHeightOffset = _browserOptions.fullscreen ? -(toolbarHeight == statusBarOffset ? statusBarOffset+10 : statusBarOffset+toolbarHeight) : -(toolbarOffset+toolbarPadding);
14621462

14631463
if ([_browserOptions.toolbarposition isEqualToString:kThemeableBrowserToolbarBarPositionTop]) {
14641464
// The webview height calculated did not take the status bar into account. Thus we need to remove status bar height to the webview height.
1465-
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, (self.webView.frame.size.height-toolbarOffset-toolbarPadding))];
1465+
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, (self.webView.frame.size.height+webviewHeightOffset))];
14661466
[self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, toolbarOffset, self.toolbar.frame.size.width, self.toolbar.frame.size.height + toolbarPadding)];
14671467
}
14681468
// When positionning the iphone to landscape mode, status bar is hidden. The problem is that we set the webview height just before with removing the status bar height. We need to adjust the phenomen by adding the preview status bar height. We had to add manually 20 (pixel) because in landscape mode, the status bar height is equal to 0.
@@ -1471,9 +1471,11 @@ - (void) rePositionViews {
14711471
}
14721472

14731473
} else {
1474-
CGFloat webviewOffset = _browserOptions.fullscreen ? 0.0 : toolbarHeight;
1474+
// iOS <=10
1475+
CGFloat webviewOffset = _browserOptions.fullscreen ? toolbarPadding + toolbarHeight - statusBarOffset : toolbarHeight;
1476+
CGFloat webviewHeightOffset = _browserOptions.fullscreen ? -(toolbarOffset+toolbarPadding+statusBarOffset) : 0;
14751477
if ([_browserOptions.toolbarposition isEqualToString:kThemeableBrowserToolbarBarPositionTop]) {
1476-
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, self.webView.frame.size.height)];
1478+
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, self.webView.frame.size.height+webviewHeightOffset)];
14771479
[self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, toolbarOffset, self.toolbar.frame.size.width, self.toolbar.frame.size.height+toolbarPadding)];
14781480
}
14791481
}

0 commit comments

Comments
 (0)