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

后端 未结 30 3275
醉话见心
醉话见心 2020-11-21 05:48

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

30条回答
  •  旧时难觅i
    2020-11-21 05:58

    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
        }
    }
    

提交回复
热议问题