Question

If you create a universal ios app in xcode and want to position elements in the code instead of the interface builder then how do you do that.

I mean do you just use iphone positioning and xcode scales it up for ipads or what?

Was it helpful?

Solution

Any graphics you can have normal and retina version. MyImage.png and MyImage@2x.png and the system will use the right one. But for all other positioning you're on your own if you're not using interface builder.

Take a look at - (void)viewDidLayoutSubviews and the various resize mask settings for your UI elements.

Many apps check the size of the display and/or use idiom to determine the basic layout needs and calculating. There's a huge difference of size from an older iPhone and fullsize iPad so simply scaling everything up is not a good approach. Better to layout according to if it's an iPad and and Iphone and to take into account the real screen dimensions.

OTHER TIPS

Any dimensions used in code are used explicitly.

The only dimension translation Cocoa-Touch does is scaling from non-retina to retina. And the only non-retina iOS7 capable devices are iPads.

So what this means is you need to write logic to place objects in one position for 3.5" iPhones, another position for 4" iPhones, and another position for iPads. iPads and iPad minis have the same non-retina resolution and the same retina resolution. The translation from non-retina to retina is handled for you. And despite being different physical sizes, the resolution is consistent between iPad sizes.

But nothing is consistent between short iPhone, tall iPhone and iPad. You have to set each of these.

Or use auto-layout. But even with auto-layout, there will likely be discrepancies between screen sizes you want to account for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top