5
votes

I'd like to have a nice start of my app by fading from the splash screen (UILaunchImageFile) into the main screen. Easy thing, I thought, just show an UIImageView with the splash screen as the very first view and then make a transition animation.

The problem is, since this is an iPad app with all four orientations supported, and splash screens for all these orientations, I would need to query which splash screen was used. I could query the current device rotation and select the image accordingly, but I wonder whether there's a better way.

So, can I query somehow which launch image was used during app start or do I need to ask for the device's current UI orientation and chose the file accordingly ?

2
Isn't the splash screen displayed automatically from the launcher (or springboard)? So, this would happen without any intervention of your code, I'd expect.Axel
Of course the real splash screen is displayed by Springboard. But the very first view is displayed immediately afterwards which is a hard transition. There is no fade or something. So I'd like to have an image view with the splash screen as image as the first view. You wouldn't see that the "real" splash screen has been replaced by an image (I know since I've seen another app do that). And then I can fade from my imageview to the real main view.DarkDust

2 Answers

4
votes

No, you can't do this automagically. Querying the device rotation and selecting an image based on that is perfectly fine.

You really only need Portrait or Landscape in this situation though, assuming you are rotating your view properly.

3
votes

As already stated by Joshua you cannot, as far as I am aware.

In case this might help someone else, if you are using asset catelogs the following code should provide the correct launch image for the current interface orientation.

NSString *suffix = nil;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    suffix = [[UIScreen mainScreen] bounds].size.height >= 568.0f ? @"-568h@2x" : @"@2x";
}
else {
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    suffix = UIInterfaceOrientationIsPortrait(orientation) ? @"-Portrait" : @"-Landscape";
    suffix = [UIScreen mainScreen].scale == 2.0 ? [suffix stringByAppendingString:@"@2x~ipad"] : [suffix stringByAppendingString:@"~ipad"];
}

NSString *launchImageName = [NSString stringWithFormat:@"LaunchImage-700%@.png",suffix];