5

I am trying to update my app to support retina displays but when it runs on a Retina MacBook Pro the @2x versions of the images aren't being used. Below are the methods I'm using in my app to set the image views.

In the XML parser class:

[[self theCurrent] setCurIcon:[NSImage imageNamed:@"snow.png"]];

Setting the NSImageView in the Current class:

[viewCurIcon setImage:curIcon];

Each image file has a standard res version and a high res version which are all in the supporting files folder of the Xcode project:

snow.png is 128x128 pixels
snow@2x.png is 256x256 pixels

I confirmed that the @2x versions are included in the app package when Xcode builds the application. Other things to note are: the app is a menu bar application with all the views inside an NSPopover, an animated GIF is used in one of the image views (no @2x version of the GIF), the app is built with Xcode 4.4 on an older MacBook Pro running OSX 10.7.4 with no retina display.

wigging
  • 8,492
  • 12
  • 75
  • 117
  • @NSPostWhenIdle Are you sure that using "snow" instead of "snow.png" will work? Everything that I've read used the filename extension. – wigging Sep 03 '12 at 04:16
  • @NSPostWhenIdle Could you submit your comment as an answer? – wigging Sep 03 '12 at 15:08
  • Sure thing, I just posted it. Did this work for you? I'm not a Mac developer just iOS and that's how it's done on that end. I just assumed it would be the same! – Mick MacCallum Sep 03 '12 at 15:10

1 Answers1

6

Try using @"snow" instead of @"snow.png". This way you are pointing to an image named "snow" and letting the OS sort out the details regarding resolution and extension rather than specifically stating the image will be named "snow.png"

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • Do you have to also increase the DPI of the retina image file? For example, the standard image file is 128x128 pixels with an image DPI of 72 px/inch while the retina image file is 256x256 pixels with an image DPI of 72 px/inch. Should the retina DPI be 144 pixels/inch? – wigging Sep 04 '12 at 00:13
  • 1
    @Gavin 72 DPI will be fine for both images, and I can't seem to find this in writing right now, but I'm pretty sure Apple recommends this. – Mick MacCallum Sep 04 '12 at 01:00
  • Let me know if you find that documentation. And according to my buddy with the retina MBP, removing the `.png` extension from the image file names fixed my problem! – wigging Sep 04 '12 at 01:17
  • @Gavin There doesn't appear to be anything in the docs about this... all I could find there was Apple recommending that icons and screenshots for the App Store's should be 72 DPI. However, I did find this article expelling things a little better: http://bjango.com/articles/designingforretina2/ – Mick MacCallum Sep 04 '12 at 01:23
  • @wigging, [Apple docs on `imageNamed:`](https://developer.apple.com/documentation/appkit/nsimage/1520015-imagenamed) say "When looking for files in the app bundle, it is better (but not required) to include the filename extension in the name parameter." I guess that's bad advice. – JWWalker Jul 31 '17 at 22:28