iOS 5.1 and Default.png

ios, ios5, ipad

Solution

For official information here take a look at: App-Related Resources

For Launch images use this format:

<basename><orientation_modifier><scale_modifier><device_modifier>.png

It looks you would be better off using:

Default.png - (iPad)

Default@2x.png - (iPad Retina)

Default~iphone.png - (iPhone)

Default@2x~iphone.png -(iPhone Retina)

This should give you proper image even if using simply:

splashView.image = [UIImage imageNamed:@"Default"]; 

Problem

I am developing an application using iOS 5.1 and I am experiencing some strange behavior with the default.png files. I have added the following files to my application: Default.png - (iPhone) Default@2x.ping - (iPhone Retina) Default-Portrait~ipad.png - (iPad) Default-Portrait@2x~ipad.png -(iPad Retina) When the application starts it seems that it selects the correct Default.png image to use for each occasion. However in my AppDelegate I have a simple splash screen to make smoother the loading of the application and the transition to the app, doing something like: ``` UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,window.frame.size.width, window.frame.size.height)]; splashView.image = [UIImage imageNamed:@"Default"]; [window addSubview:splashView]; [window bringSubviewToFront:splashView]; ``` However the `[UIImage imageNamed:@"Default"]` in turn does not select the correct file for each device, and I believe the problem is the `-Portrait` part of the filename. So as a quick solution I did this: ``` if( ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ) { // Force the image used by ipads if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) { splashView.image = [UIImage imageNamed:@"Default-Portrait@2x~ipad"]; } else { splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad"]; } } else splashView.image = [UIImage imageNamed:@"Default"]; ``` Is this how I should be doing this? Does this look funny to you?

Original source