5

I have a question that may sound odd, but being somewhat of a newbie, I am guessing no question is a stupid question...

Do I need separate storyboards for all four devices?

Right now I have two storyboards, one for iPhone and one for iPad, but what I get my view frame it always shows the size of the device, not the retina device. So for example on the iPhone my view size is 320x460, and for iPhone Retina it shows the same... likewise for iPad.

Thanks

LilMoke
  • 3,176
  • 7
  • 48
  • 88
  • Don't be mistaken, there are lots of stupid questions out there! He who says there are no stupid questions, just stupid answers, is an idiot. This, however, is a great question! – Jake Mar 19 '12 at 16:18

2 Answers2

5

No, you don't. Yes it's the same resolution for the developer point of view. iOS will make all the adjustment. The only important issue is that if you use images in your app bundle (like tab icons) you have to add one for not retine a one for retina (with double resolution). For example if you have icon.png of 24x24px, you have to add icon@2x.png of 48x48px. iOS automatically will replace your icon for the "@2x" filename in retina divices.

LuisEspinoza
  • 8,508
  • 6
  • 35
  • 57
  • Ok, understood. That is what I was thinking, but for the images, will it always choose the @2x file or the ~ipad file if it is specified. Another way to put it is, are there cases where i will need to detect the device and change the filename two reference a different image? – LilMoke Mar 19 '12 at 16:18
  • I'm not sure if in runtime will detect an image that, for example, you download. But i'm sure that you can specify the retina ready image when you detect a retina display. This answer can help you with the detection http://stackoverflow.com/a/3294120/1014773 – LuisEspinoza Mar 19 '12 at 16:24
  • thanks i will take a look. I was not talking about images I download, just images from my main bundle. Will UIImage always pick the right image, that was really the question. – LilMoke Mar 19 '12 at 16:25
  • Ahh, yes. Sure if the image are from your bundle, if you add "@2x" to the filename, and iOS will use it in the case that the device is Retina – LuisEspinoza Mar 19 '12 at 16:34
0

You can differentiate the graphic content of your application, but the views / storyboard for the moment I do not think you can.

If you want to take advantage of the resolution of retina screens you can use the @2x trick.

This consists of the following, we give the example of the application icon_

  • Icon.png ( default icon for the iphone at 57x57 pixels )
  • Icon@2x.png ( default icon for the iphone with retina display at 114x114 pixels )

  • Icon~iPad.png ( default icon for the ipad at 72x72 pixels )

  • Icon~iPad@2x.png ( default icon for the ipad with retina display at 144x144 pixels )

This trick is useful for all your graphic content and no requires extra code when you make your interfaces and your code. When you have to specify the graphics file to be used, always specify the file which does not have the "@2x".

I hope that is helpful.

angeldiaz
  • 26
  • 4
  • Yes, the example for the application icon is always used... but does this technique works all the time? Will this always work for a UIImage, or are their times where I will need to specify the proper image? – LilMoke Mar 19 '12 at 16:24
  • It works always and no require extra code for change the image. You only references the normal image and iOS do the rest ;) If you're interested download this sample code and you'll see it in action: (link)http://www.angeldiaz.es/idec-upf/leccion07/Example37.tar.gz Remember to change the simulator destination to view it working. – angeldiaz Mar 21 '12 at 10:18
  • 1
    This is not sufficient. Not all the UIImage s has got a filename associated.. You can obtain an UIImage from a graphic context and in that case you must take care of half/double resolution issues with the scale value. – hariseldon78 Jul 28 '12 at 16:53