Search code examples
iphoneobjective-cipadiphone-sdk-3.0ios4

Trouble displaying "@2x.png" images in iPad


My iphone app has two images: "cat.png" and "cat@2x.png"

I heard that if we want to display bigger image (for iPad version), then you give name as "@2x.png" & it automatically detects device & display bigger image in iPad.

Is that true? If yes, I have done the same thing, but it does not display "cat@2x.png" when I check in iPad.

What could be wrong?

NOTE: I know there are post discussing this thing for icon.png BUT in my case I am refering to all images.


Solution

  • @2x is the extension for the iPhone 4 retina display. You want to store two versions of the image if you are releasing your app for the iPhone. e.g. myimage@2x.png and myimage.png.

    Read this: https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreensInViews/SupportingHiResScreensInViews.html#//apple_ref/doc/uid/TP40010156-CH15-SW8

    Excerpt:

    Standard: <ImageName><device_modifier>.<filename_extension> 
    High resolution: <ImageName>@2x<device_modifier>.<filename_extension>
    

    The <ImageName> and <filename_extension> portions of each name specify the usual name and extension for the file. The <device_modifier> portion is optional and contains either the string ~ipad or ~iphone.

    You include one of these modifiers when you want to specify different versions of an image for iPad and iPhone. The inclusion of the @2x modifier for the high-resolution image is new and lets the system know that the image is the high-resolution variant of the standard image.