From 80c8e56fb08979582a1dd31788607f35be635a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20C=C3=A9sar?= Date: Sat, 16 Jan 2016 11:45:17 +0100 Subject: [PATCH] CB-10305 Gray bar appears in the wrong place on iOS This closes #137 --- src/ios/CDVInAppBrowser.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index b7820f3..8b2c90c 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -755,6 +755,10 @@ return UIStatusBarStyleDefault; } +- (BOOL)prefersStatusBarHidden { + return NO; +} + - (void)close { [CDVUserAgentUtil releaseLock:&_userAgentLockToken]; @@ -1000,13 +1004,26 @@ // simplified from: http://stackoverflow.com/a/25669695/219684 - UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame]; + UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]]; bgToolbar.barStyle = UIBarStyleDefault; + [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [self.view addSubview:bgToolbar]; [super viewDidLoad]; } +- (CGRect) invertFrameIfNeeded:(CGRect)rect { + // We need to invert since on iOS 7 frames are always in Portrait context + if (!IsAtLeastiOSVersion(@"8.0")) { + if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { + CGFloat temp = rect.size.width; + rect.size.width = rect.size.height; + rect.size.height = temp; + rect.origin = CGPointZero; + } + } + return rect; +} #pragma mark CDVScreenOrientationDelegate