From 75327c88e4463ef3e3507424e4bb411c4365b9ca Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Tue, 14 Jan 2014 20:13:40 +0100 Subject: [PATCH] [CB-3562] Fix aspect ratio on landscape-only iPhone applications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The splash screen is shown with a faulty aspect ratio for landscape-only applications on iPhone/iPod touch devices. This is fixed by applying a 90° rotational transformation. Signed-off-by: Michael Hanselmann --- src/ios/CDVSplashScreen.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ios/CDVSplashScreen.m b/src/ios/CDVSplashScreen.m index 3b59627..093fc87 100644 --- a/src/ios/CDVSplashScreen.m +++ b/src/ios/CDVSplashScreen.m @@ -173,6 +173,18 @@ CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero; CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size; + UIInterfaceOrientation orientation = self.viewController.interfaceOrientation; + CGAffineTransform imgTransform = CGAffineTransformIdentity; + + /* If and only if an iPhone application is landscape-only as per + * UISupportedInterfaceOrientations, the view controller's orientation is + * landscape. In this case the image must be rotated in order to appear + * correctly. + */ + if (UIInterfaceOrientationIsLandscape(orientation) && !CDV_IsIPad()) { + imgTransform = CGAffineTransformMakeRotation(M_PI / 2); + imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width); + } // There's a special case when the image is the size of the screen. if (CGSizeEqualToSize(screenSize, imgBounds.size)) { @@ -195,6 +207,7 @@ imgBounds.size.width *= ratio; } + _imageView.transform = imgTransform; _imageView.frame = imgBounds; }