xcodexcode4.2resolutionretina-displayimagenamed

Retina support imageNamed @2x not working


Possible Duplicate:
iOS 5.1 with Xcode 4.2 and retina in iPad 3

I am trying to make my app load on iPad 2 (since its running great on iPad 3). I have downscaled the images and now have 2 sets of images like: image.png and image@2x.png. When I try to load the image with:

someImageView.image = [UIImage imageNamed:@"image.png"];

Or through the IB, it does not give me the result I expected (like choosing the correct version of the image depending on the iPad's display as stated here) and only displays the image.png no matter which iPad runs the application, though when I try to import the image through:

NSString* imagePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
UIImage* someImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
someImageView.image = someImage;

This works just fine and when I run the app on iPad 3 it uses the @2x png file. Although this works, I am not sure I have to allocate and release every single image I use, since I use some images through IB. Is that a normal behaviour?

I used SDK 4, 4.2 and 5 but nothing changed, also I am using Xcode 4.2, since I dont want to switch to Lion.

Any help is greatly appreciated!

*UPDATE: UIImage switches to @2x when [UIScreen mainScreen].scale is returning 2. When I check that, it returns 1, which is the reason @2x is not activated. So does anyone know if 4.2 does not recognize iPad3 retina display? I found something similar here.

*UPDATE 2: I managed to get this working by merging SDK 5.1 into the Xcode and using it as base SDK. It didn't work when I had both SDK 5 and 5.1 in the SDKs folder, worked as a charm when I removed the SDK 5 version.


Solution

  • It's not working by default, because Xcode 4.3.1 was the first version to support the new iPad (retina)

    If you want to get it working anyways, check this answer