tvOS launch images are now properly supported.
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h
index 5336f71..edf09f5 100644
--- a/src/video/uikit/SDL_uikitappdelegate.h
+++ b/src/video/uikit/SDL_uikitappdelegate.h
@@ -24,6 +24,7 @@
@interface SDLLaunchScreenController : UIViewController
- (instancetype)init;
+- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
- (void)loadView;
@end
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 60aeeda..c94c78a 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -155,29 +155,29 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
}
if (!self.view) {
-#if !TARGET_OS_TV
NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"];
- UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
NSString *imagename = nil;
UIImage *image = nil;
int screenw = (int)([UIScreen mainScreen].bounds.size.width + 0.5);
int screenh = (int)([UIScreen mainScreen].bounds.size.height + 0.5);
+#if !TARGET_OS_TV
+ UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
+
/* We always want portrait-oriented size, to match UILaunchImageSize. */
if (screenw > screenh) {
int width = screenw;
screenw = screenh;
screenh = width;
}
+#endif
/* Xcode 5 introduced a dictionary of launch images in Info.plist. */
if (launchimages) {
for (NSDictionary *dict in launchimages) {
- UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
- NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
- NSString *sizestring = dict[@"UILaunchImageSize"];
- NSString *orientstring = dict[@"UILaunchImageOrientation"];
+ NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
+ NSString *sizestring = dict[@"UILaunchImageSize"];
/* Ignore this image if the current version is too low. */
if (minversion && !UIKit_IsSystemVersionAtLeast(minversion.doubleValue)) {
@@ -192,6 +192,10 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
}
}
+#if !TARGET_OS_TV
+ UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
+ NSString *orientstring = dict[@"UILaunchImageOrientation"];
+
if (orientstring) {
if ([orientstring isEqualToString:@"PortraitUpsideDown"]) {
orientmask = UIInterfaceOrientationMaskPortraitUpsideDown;
@@ -208,6 +212,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
if ((orientmask & (1 << curorient)) == 0) {
continue;
}
+#endif
imagename = dict[@"UILaunchImageName"];
}
@@ -215,7 +220,9 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
if (imagename) {
image = [UIImage imageNamed:imagename];
}
- } else {
+ }
+#if !TARGET_OS_TV
+ else {
imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
if (imagename) {
@@ -226,11 +233,13 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
image = SDL_LoadLaunchImageNamed(@"Default", screenh);
}
}
+#endif
if (image) {
UIImageView *view = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIImageOrientation imageorient = UIImageOrientationUp;
+#if !TARGET_OS_TV
/* Bugs observed / workaround tested in iOS 8.3, 7.1, and 6.1. */
if (UIInterfaceOrientationIsLandscape(curorient)) {
if (atleastiOS8 && image.size.width < image.size.height) {
@@ -254,15 +263,13 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
}
}
}
+#endif
/* Create the properly oriented image. */
view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient];
self.view = view;
}
-#else /* !TARGET_OS_TV */
- return nil;
-#endif
}
return self;
@@ -363,10 +370,11 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
* called), so we show the launch screen programmatically until the first
* time events are pumped. */
UIViewController *vc = nil;
+ NSString *screenname = nil;
- /* TODO: Try to load the 1080p launch image on tvOS. */
+ /* tvOS only uses a plain launch image. */
#if !TARGET_OS_TV
- NSString *screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
+ screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
if (screenname && UIKit_IsSystemVersionAtLeast(8.0)) {
@try {
@@ -380,11 +388,11 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
/* Do nothing (there's more code to execute below). */
}
}
+#endif
if (vc == nil) {
vc = [[SDLLaunchScreenController alloc] initWithNibName:screenname bundle:bundle];
}
-#endif
if (vc.view) {
launchWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];