Updated Branches:
  refs/heads/dev fe288ec3c -> 75327c88e

[CB-3562] Fix aspect ratio on landscape-only iPhone applications

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 <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/75327c88
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/75327c88
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/75327c88

Branch: refs/heads/dev
Commit: 75327c88e4463ef3e3507424e4bb411c4365b9ca
Parents: fe288ec
Author: Michael Hanselmann <[email protected]>
Authored: Tue Jan 14 20:13:40 2014 +0100
Committer: Shazron Abdullah <[email protected]>
Committed: Wed Jan 15 16:33:32 2014 -0800

----------------------------------------------------------------------
 src/ios/CDVSplashScreen.m | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/75327c88/src/ios/CDVSplashScreen.m
----------------------------------------------------------------------
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;
 }
 

Reply via email to