Fixed the extended launch screen causing minor visual issues when rotating the screen in some circumstances. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Sat, 24 Jan 2015 23:53:41 -0400
branchiOS-improvements
changeset 9534 5b2b50804caa
parent 9533 e5693e855338
child 9535 a66a7f7e8cd8
Fixed the extended launch screen causing minor visual issues when rotating the screen in some circumstances.
src/video/uikit/SDL_uikitappdelegate.h
src/video/uikit/SDL_uikitappdelegate.m
--- a/src/video/uikit/SDL_uikitappdelegate.h	Thu Jan 15 01:15:24 2015 -0400
+++ b/src/video/uikit/SDL_uikitappdelegate.h	Sat Jan 24 23:53:41 2015 -0400
@@ -25,7 +25,6 @@
 
 - (instancetype)init;
 - (void)loadView;
-- (BOOL)shouldAutorotate;
 - (NSUInteger)supportedInterfaceOrientations;
 
 @end
--- a/src/video/uikit/SDL_uikitappdelegate.m	Thu Jan 15 01:15:24 2015 -0400
+++ b/src/video/uikit/SDL_uikitappdelegate.m	Sat Jan 24 23:53:41 2015 -0400
@@ -115,7 +115,9 @@
     return image;
 }
 
-@implementation SDLLaunchScreenController
+@implementation SDLLaunchScreenController {
+    UIInterfaceOrientationMask supportedOrientations;
+}
 
 - (instancetype)init
 {
@@ -126,6 +128,9 @@
     NSBundle *bundle = [NSBundle mainBundle];
     NSString *screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
 
+    /* Normally we don't want to rotate from the initial orientation. */
+    supportedOrientations = (1 << [UIApplication sharedApplication].statusBarOrientation);
+
     /* Launch screens were added in iOS 8. Otherwise we use launch images. */
     if (screenname && UIKit_IsSystemVersionAtLeast(8.0)) {
         @try {
@@ -211,6 +216,12 @@
         }
 
         if (image) {
+            if (image.size.width > image.size.height) {
+                supportedOrientations = UIInterfaceOrientationMaskLandscape;
+            } else {
+                supportedOrientations = UIInterfaceOrientationMaskPortrait;
+            }
+
             self.view = [[UIImageView alloc] initWithImage:image];
         }
     }
@@ -223,14 +234,9 @@
     /* Do nothing. */
 }
 
-- (BOOL)shouldAutorotate
-{
-    return YES;
-}
-
 - (NSUInteger)supportedInterfaceOrientations
 {
-    return UIInterfaceOrientationMaskAll;
+    return supportedOrientations;
 }
 
 @end
@@ -333,7 +339,7 @@
 
     SDL_SetMainReady();
     [self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
-    
+
     return YES;
 }