Retina iOS device does not display @ 2X image, it displays 1X image

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

I am using Xcode 4.2.1 Build 4D502, the application is for iOS 5.

I created a test application (master / part) and added two images.

iconTest.png 24 x 24 iconTest@2X.png 48 x 48 Each image is unique, so I can easily determine which one is displayed.

In ViewDidLoad, I add 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 application in iOS Simulator, it correctly displays the icon for the retina iOS device. In the simulator, Hardware-> Device-> is installed on the iPhone (Retina). And when I pause the application and look at the buttonImage object, I see that the scale is set to 2.

It works as expected!

However, when I attach my iPhone 4 and launch the application, a lower resolution image appears. And, when I pause the application and look at the buttonImage object, I see that the scale is 1.

This is not expected behavior.

Any ideas on why this is different from the simulator and the real iOS device?

Is this a known issue? Is a workaround known?

Thanks, Brian.

+6
source share
1 answer

File names are case sensitive on the iPhone, but not on the iPhone Simulator. You need to use @2x instead of @2x .

+17
source

Source: https://habr.com/ru/post/904556/


All Articles