tvOS launch images are now properly supported.
authorAlex Szpakowski
Sun, 25 Sep 2016 11:46:25 -0300
changeset 10371155d4f094f62
parent 10370 d90965a3b100
child 10372 19b0437c4099
tvOS launch images are now properly supported.
src/video/uikit/SDL_uikitappdelegate.h
src/video/uikit/SDL_uikitappdelegate.m
     1.1 --- a/src/video/uikit/SDL_uikitappdelegate.h	Sun Sep 25 00:23:35 2016 -0300
     1.2 +++ b/src/video/uikit/SDL_uikitappdelegate.h	Sun Sep 25 11:46:25 2016 -0300
     1.3 @@ -24,6 +24,7 @@
     1.4  @interface SDLLaunchScreenController : UIViewController
     1.5  
     1.6  - (instancetype)init;
     1.7 +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
     1.8  - (void)loadView;
     1.9  
    1.10  @end
     2.1 --- a/src/video/uikit/SDL_uikitappdelegate.m	Sun Sep 25 00:23:35 2016 -0300
     2.2 +++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun Sep 25 11:46:25 2016 -0300
     2.3 @@ -155,29 +155,29 @@
     2.4      }
     2.5  
     2.6      if (!self.view) {
     2.7 -#if !TARGET_OS_TV
     2.8          NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"];
     2.9 -        UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
    2.10          NSString *imagename = nil;
    2.11          UIImage *image = nil;
    2.12  
    2.13          int screenw = (int)([UIScreen mainScreen].bounds.size.width + 0.5);
    2.14          int screenh = (int)([UIScreen mainScreen].bounds.size.height + 0.5);
    2.15  
    2.16 +#if !TARGET_OS_TV
    2.17 +        UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
    2.18 +
    2.19          /* We always want portrait-oriented size, to match UILaunchImageSize. */
    2.20          if (screenw > screenh) {
    2.21              int width = screenw;
    2.22              screenw = screenh;
    2.23              screenh = width;
    2.24          }
    2.25 +#endif
    2.26  
    2.27          /* Xcode 5 introduced a dictionary of launch images in Info.plist. */
    2.28          if (launchimages) {
    2.29              for (NSDictionary *dict in launchimages) {
    2.30 -                UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
    2.31 -                NSString *minversion   = dict[@"UILaunchImageMinimumOSVersion"];
    2.32 -                NSString *sizestring   = dict[@"UILaunchImageSize"];
    2.33 -                NSString *orientstring = dict[@"UILaunchImageOrientation"];
    2.34 +                NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
    2.35 +                NSString *sizestring = dict[@"UILaunchImageSize"];
    2.36  
    2.37                  /* Ignore this image if the current version is too low. */
    2.38                  if (minversion && !UIKit_IsSystemVersionAtLeast(minversion.doubleValue)) {
    2.39 @@ -192,6 +192,10 @@
    2.40                      }
    2.41                  }
    2.42  
    2.43 +#if !TARGET_OS_TV
    2.44 +                UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
    2.45 +                NSString *orientstring = dict[@"UILaunchImageOrientation"];
    2.46 +
    2.47                  if (orientstring) {
    2.48                      if ([orientstring isEqualToString:@"PortraitUpsideDown"]) {
    2.49                          orientmask = UIInterfaceOrientationMaskPortraitUpsideDown;
    2.50 @@ -208,6 +212,7 @@
    2.51                  if ((orientmask & (1 << curorient)) == 0) {
    2.52                      continue;
    2.53                  }
    2.54 +#endif
    2.55  
    2.56                  imagename = dict[@"UILaunchImageName"];
    2.57              }
    2.58 @@ -215,7 +220,9 @@
    2.59              if (imagename) {
    2.60                  image = [UIImage imageNamed:imagename];
    2.61              }
    2.62 -        } else {
    2.63 +        }
    2.64 +#if !TARGET_OS_TV
    2.65 +        else {
    2.66              imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
    2.67  
    2.68              if (imagename) {
    2.69 @@ -226,11 +233,13 @@
    2.70                  image = SDL_LoadLaunchImageNamed(@"Default", screenh);
    2.71              }
    2.72          }
    2.73 +#endif
    2.74  
    2.75          if (image) {
    2.76              UIImageView *view = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    2.77              UIImageOrientation imageorient = UIImageOrientationUp;
    2.78  
    2.79 +#if !TARGET_OS_TV
    2.80              /* Bugs observed / workaround tested in iOS 8.3, 7.1, and 6.1. */
    2.81              if (UIInterfaceOrientationIsLandscape(curorient)) {
    2.82                  if (atleastiOS8 && image.size.width < image.size.height) {
    2.83 @@ -254,15 +263,13 @@
    2.84                      }
    2.85                  }
    2.86              }
    2.87 +#endif
    2.88  
    2.89              /* Create the properly oriented image. */
    2.90              view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient];
    2.91  
    2.92              self.view = view;
    2.93          }
    2.94 -#else /* !TARGET_OS_TV */
    2.95 -        return nil;
    2.96 -#endif
    2.97      }
    2.98  
    2.99      return self;
   2.100 @@ -363,10 +370,11 @@
   2.101       * called), so we show the launch screen programmatically until the first
   2.102       * time events are pumped. */
   2.103      UIViewController *vc = nil;
   2.104 +    NSString *screenname = nil;
   2.105  
   2.106 -    /* TODO: Try to load the 1080p launch image on tvOS. */
   2.107 +    /* tvOS only uses a plain launch image. */
   2.108  #if !TARGET_OS_TV
   2.109 -    NSString *screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
   2.110 +    screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
   2.111  
   2.112      if (screenname && UIKit_IsSystemVersionAtLeast(8.0)) {
   2.113          @try {
   2.114 @@ -380,11 +388,11 @@
   2.115              /* Do nothing (there's more code to execute below). */
   2.116          }
   2.117      }
   2.118 +#endif
   2.119  
   2.120      if (vc == nil) {
   2.121          vc = [[SDLLaunchScreenController alloc] initWithNibName:screenname bundle:bundle];
   2.122      }
   2.123 -#endif
   2.124  
   2.125      if (vc.view) {
   2.126          launchWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];