问题
As suggested here, in Interface Builder i've assigned to a full size Image View the "LaunchImage.png" parameter for the "Image" attribute, being associated at runtime by iOS.

But at runtime, in any device (iPhone, iPad, with/without retina), the image picked is always the 640 × 960 pixels size image, thus ignoring other sizes.
Is there any way to make iOS automatically picking the right image base on device and resolution?
回答1:
Yes there is an easier way to do this in XCode 5.
- Click on your Xcode General Tab
- Then scroll below and look for Launch images. See the little gray arrow click that
- You can now drag and drop launch images for specific devices.
- You can also select different launch images between iOS6 & iOS7 devices if you so choose.
- Correct launch images will be picked up automatically for each device and screens size.
See these screenshots.



回答2:
For now, the only method i've found is to handle manually in code the LaunchImage.png:
self.splashImage.contentMode = UIViewContentModeScaleAspectFit;
if (IS_IPHONE())
{
if (!IS_RETINA)
{
self.splashImage.image = [UIImage imageNamed:@"LaunchImage.png"];
}
else
{
if (IS_PHONEPOD5())
{
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-568h@2x.png"];
}
else
{
self.splashImage.image = [UIImage imageNamed:@"LaunchImage@2x.png"];
}
}
}
else if (IS_IPAD())
{
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait)
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
if (!IS_RETINA)
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad"];
else
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad"];
}
else
{
if (!IS_RETINA)
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-Portrait~ipad"];
else
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-Portrait@2x~ipad"];
}
}
else // landscape
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
if (!IS_RETINA)
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad"];
else
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
}
else
{
if (!IS_RETINA)
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-Landscape~ipad"];
else
self.splashImage.image = [UIImage imageNamed:@"LaunchImage-Landscape@2x~ipad"];
}
}
}
where IS_IPHONE, IS_RETINA, etc. are macro defined as:
#define IS_PHONEPOD5() ([UIScreen mainScreen].bounds.size.height == 568.0f && [UIScreen mainScreen].scale == 2.f && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
#define IS_IPHONE() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
来源:https://stackoverflow.com/questions/21437970/xcode-5-asset-catalog-how-to-automatically-pick-launchimage-at-correct-size