How to develop or migrate apps for iPhone 5 screen resolution?

The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels).

What is required to develop new or transition already existing applications to the new screen size?

What should we keep in mind to make applications "universal" for both the older displays and the new widescreen aspect ratio?


  • Download and install latest version of Xcode.
  • Set a Launch Screen File for your app (in the general tab of your target settings). This is how you get to use the full size of any screen, including iPad split view sizes in iOS 9.
  • Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly, or used Auto Layout.
  • If you didn't, adjust your view layouts, preferably with Auto Layout.
  • If there is something you have to do for the larger screens specifically, then it looks like you have to check height of [[UIScreen mainScreen] bounds] as there seems to be no specific API for that. As of iOS 8 there are also size classes that abstract screen sizes into regular or compact vertically and horizontally and are recommended way to adapt your UI.

  • If you have an app built for iPhone 4S or earlier, it'll run letterboxed on iPhone 5.

    To adapt your app to the new taller screen, the first thing you do is to change the launch image to: Default-568h@2x.png. Its size should be 1136x640 (HxW). Yep, having the default image in the new screen size is the key to let your app take the whole of new iPhone 5's screen.

    (Note that the naming convention works only for the default image. Naming another image "Image-568h@2x.png" will not cause it to be loaded in place of "Image@2x.png". If you need to load different images for different screen sizes, you'll have to do it programmatically.)

    If you're very very lucky, that might be it... but in all likelihood, you'll have to take a few more steps.

  • Make sure, your Xibs/Views use auto-layout to resize themselves.
  • Use springs and struts to resize views.
  • If this is not good enough for your app, design your xib/storyboard for one specific screen size and reposition programmatically for the other.
  • In the extreme case (when none of the above suffices), design the two Xibs and load the appropriate one in the view controller.

    To detect screen size:

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 480)
        {
            // iPhone Classic
        }
        if(result.height == 568)
        {
            // iPhone 5
        }
    }
    

    The only really required thing to do is to add a launch image named "Default-568h@2x.png" to the app resources, and in general case (if you're lucky enough) the app will work correctly.

    In case the app does not handle touch events, then make sure that the key window has the proper size. The workaround is to set the proper frame:

    [window setFrame:[[UIScreen mainScreen] bounds]]
    

    There are other issues not related to screen size when migrating to iOS 6. Read iOS 6.0 Release Notes for details.

    链接地址: http://www.djcxy.com/p/39474.html

    上一篇: UIView动画不一致的结果

    下一篇: 如何开发或迁移iPhone 5屏幕分辨率的应用程序?