Fixed the extended launch screen causing minor visual issues when rotating the screen in some circumstances.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h
index cc4494d..45dd91e 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 3306f38..2ae6182 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -115,7 +115,9 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
return image;
}
-@implementation SDLLaunchScreenController
+@implementation SDLLaunchScreenController {
+ UIInterfaceOrientationMask supportedOrientations;
+}
- (instancetype)init
{
@@ -126,6 +128,9 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
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 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
}
if (image) {
+ if (image.size.width > image.size.height) {
+ supportedOrientations = UIInterfaceOrientationMaskLandscape;
+ } else {
+ supportedOrientations = UIInterfaceOrientationMaskPortrait;
+ }
+
self.view = [[UIImageView alloc] initWithImage:image];
}
}
@@ -223,14 +234,9 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
/* Do nothing. */
}
-- (BOOL)shouldAutorotate
-{
- return YES;
-}
-
- (NSUInteger)supportedInterfaceOrientations
{
- return UIInterfaceOrientationMaskAll;
+ return supportedOrientations;
}
@end
@@ -333,7 +339,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
SDL_SetMainReady();
[self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
-
+
return YES;
}