From 3e17fbee7e779c7e27d3b2c6974a3ca18031f19d Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 24 Jan 2015 23:53:41 -0400 Subject: [PATCH] Fixed the extended launch screen causing minor visual issues when rotating the screen in some circumstances. --- src/video/uikit/SDL_uikitappdelegate.h | 1 - src/video/uikit/SDL_uikitappdelegate.m | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h index cc4494dbbf3d3..45dd91e4055f0 100644 --- a/src/video/uikit/SDL_uikitappdelegate.h +++ b/src/video/uikit/SDL_uikitappdelegate.h @@ -25,7 +25,6 @@ - (instancetype)init; - (void)loadView; -- (BOOL)shouldAutorotate; - (NSUInteger)supportedInterfaceOrientations; @end diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 3306f38e93cb9..2ae61827f8daf 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -115,7 +115,9 @@ int main(int argc, char **argv) return image; } -@implementation SDLLaunchScreenController +@implementation SDLLaunchScreenController { + UIInterfaceOrientationMask supportedOrientations; +} - (instancetype)init { @@ -126,6 +128,9 @@ - (instancetype)init 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 @@ - (instancetype)init } if (image) { + if (image.size.width > image.size.height) { + supportedOrientations = UIInterfaceOrientationMaskLandscape; + } else { + supportedOrientations = UIInterfaceOrientationMaskPortrait; + } + self.view = [[UIImageView alloc] initWithImage:image]; } } @@ -223,14 +234,9 @@ - (void)loadView /* Do nothing. */ } -- (BOOL)shouldAutorotate -{ - return YES; -} - - (NSUInteger)supportedInterfaceOrientations { - return UIInterfaceOrientationMaskAll; + return supportedOrientations; } @end @@ -333,7 +339,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( SDL_SetMainReady(); [self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0]; - + return YES; }