21
votes

I'm looking to put iPad retina (crazy!) quality images into my app for the 'New iPad's launch on the 16th Martch. However I can't find the correct suffix for my file names anywhere in the documents!

I use @2x suffix for iPhone and iPod retina display. If anyone else knows what it is/will be for the iPad and, even more, can show me a link to the official documents on this I'd really appreciate it.

Thanks! :-D

EXTRA:

Thought I'd just leave a bit of code I've started using to use my iPhone @2x images for the iPad non-retina ones (as most of my @2x~iphone and ~ipad images were the same and duplicates are just a waste of space).

+ (UIImage*)imageNamedSmart:(NSString*)name
{
    UIImage *returnImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@", name]];

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
        {
            // iPad Scale 2  i.e. 3rd Gen iPad
        }
        else
        {
            // iPad Scale 1  i.e. 1st and 2nd Gen iPad
            return [UIImage imageNamed:[NSString stringWithFormat:@"%@@2x", name]];
        }
    }
    return returnImage;
 }

This means instead of calling:
[UIImage imageNamed:@"imageName"]

You call:
[self imageNamedSmart:@"imageName"]

Hope this help people a bit more. :-D

(I found this idea by goggling but I can't find the original site to link, so thank you whoever you were.)

2
Hint: imageNamed: does all the work for you already. It knows about all 4 resolutions and prefixes. ;-)Constantino Tsarouhas
Yeah but you'd still have to put double the image files in, each with there own name. This way it means you can use a [email protected] for the name~ipad.png with only one image and the code works out what to use. And as I found out when you have a universal app with iPhone and iPad retina, it gets big, fast. :-DBaza207
Indeed, this is probably the biggest downside of universal apps: bigger size.Constantino Tsarouhas

2 Answers

38
votes

You will have to append @2x~ipad to the name of your image in order to support retina graphics.

0
votes

If both the iPhone and iPad retina images are the same size, then use only one image with the @2x suffix. In this case, even the iPad retina uses this image.

If the iPhone and iPad retina images are not the same size, then use an image with the @2x suffix for the iPhone and another image with the @2x~ipad suffix for the iPad. For example, the launch images have different sizes, so you might need [email protected] and Default@2x~ipad.png.