Search code examples
iphoneiosuiviewstoryboardiphone-5

Best way to manage screen height differences on iPhone 5 and others


What is the best way to manage screen height differences between iPhone 5 and other versions?

If we use the storyboard or xib it will resize it accordingly. But if the whole view is build programmatically, how we take care of this issue.

Currently what I do is that I get the whole screen height and set the rest of the UI elements according to this height like height * .7 or height *.5 ..

But still it didn’t give me the best experience.

Thanks,


Solution

  • You can check for [UIScreen mainScreen].bounds.size.height(may be, use it as a static method or do a #define) and do the screen design based on the screen height. Another way is to use the view.autoresizingMask property to adjust the views.

    for eg:-

    view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    

    If you are building for iOS 6, you can use Auto layout features.