Xcode's default Images.xcassets
file has a slot for LaunchImage
, where for a portrait iPhone app there are 5 possible slots.
According to the documentation, to get an image properly sized from the xcassets
file, just use [UIImage imageNamed:]
.
However, running the following code on iPhone Retine (4-inch) simulator:
UIImage *splashImage = [UIImage imageNamed:@"LaunchImage"];
NSLog(@"%@", NSStringFromCGSize(splashImage.size));
produces the following output:
{320, 480}
which is obviously the wrong size.
I have made sure that the mappings in the xcassets file are correct, and have confirmed all dimensions. It also seems that I cannot request a specific image from a given set in the xcassets file, meaning I cannot do:[UIImage imageNamed:@"LaunchImageR4"]
.
And since the files are added to an xcassets file, I also do not have access to the raw image files, so a custom solution seems out of the question.
Does anyone have any idea how I would solve this issue?
I believe that the correct launch image is loaded automatically at startup. It is not meant to be pulled from
xcassets
during runtime. Since it is at runtime, you will have to do your own check for which device is being used, as the image catalog is only setup to pull retina vs. non-retina using the @2x postfix (not the size of the device).You can use this post to determine which device is being used and load the correct image by name.