3

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.

  • I have tried not using someImageView.image = [UIImage imageNamed:@"image.png"]; and just pick the image "image.png" in the IB slot. Didn't work.
  • I tried with just typing image in the IB slot. Didn't work. It picks up image.png no matter what.
  • I tried using someImageView.image = [UIImage imageNamed:@"image@2x.png"]; It shows the 2x image in any device.
  • I tried using image@2x~ipad.png and image~ipad.png . Didn't work.
  • All sets of images are named correct, size is correct and have all been imported to the project in the same group/folder.
  • It is not a universal, but an iPad application.
  • I have cleaned the build several times during the process.

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.

Community
  • 1
  • 1
madmax21
  • 33
  • 1
  • 5

2 Answers2

0

have you tried adding the ~ipad suffix to your images? so your retina iPad image should be renamed and called like this:

[UIImage imageNamed:@"image@2x~ipad.png"]

hope this helps.

KDaker
  • 5,899
  • 5
  • 31
  • 44
0

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

Community
  • 1
  • 1
brainray
  • 12,512
  • 11
  • 67
  • 116
  • Thanks for taking the time to reply:) I have already done this to get Xcode 4.2 working with iOS 5 but this hasn't changed anything. `UIScreen` scale still returns 1, so `UIImage imageNamed` doesn't pick up.. – madmax21 Oct 01 '12 at 20:29
  • I run the whole process again and since everyone said it would work I tried to remove the 5.0 SDK and keep only the 5.1 SDK. For some reason now it works! Thanks for pushing me to work this out more thoroughly! – madmax21 Oct 01 '12 at 21:28