Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retina iOS device does not show the @2X image, it shows the 1X image

Retina iOS device does not show the @2X image, it shows the 1X image.

I'm using Xcode 4.2.1 Build 4D502, the app is targeting iOS 5.

I've created a test app (Master/Detail) and added two images.

iconTest.png 24 x 24 [email protected] 48 x 48 Each image is unique so it I can easily tell which one is being displayed.

In the ViewDidLoad I'm adding a button to the navigation controller...

UIImage *buttonImage =  [UIImage imageNamed:@"iconTest.png"];
UIBarButtonItem *button = [[UIBarButtonItem alloc] 
                           initWithImage:buttonImage
                                   style:UIBarButtonItemStyleBordered
                                  target:self
                                  action:@selector(share)];
self.navigationItem.rightBarButtonItem = button;

When I run this test app in the iOS Simulator it correctly displays the icon for a retina iOS device. In the simulator, the Hardware->Device-> is set to iPhone (Retina). And when I pause the app and look at the buttonImage object I can see the scale is set to 2.

This works as expected!

However, when I attach my iPhone 4 and run the app the lower resolution image shows up. And, when I pause the app and look at the buttonImage object I can see the scale is 1.

This is not the expected behavior.

Any ideas about why this is different between the simulator and the real iOS device?

Is this a known issue? Is there a known workaround?

Thanks, Brian.

like image 341
Brian Fritz Avatar asked Dec 27 '11 21:12

Brian Fritz


1 Answers

Filenames are case sensitive on the iPhone but not on the iPhone Simulator. You need to use @2x instead of @2X.

like image 103
Mark Adams Avatar answered Oct 14 '22 21:10

Mark Adams