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

后端 未结 30 3277
醉话见心
醉话见心 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 06:18

    I guess, it is not going to work in all cases, but in my particular project it avoided me from duplication of NIB-files:

    Somewhere in common.h you can make these defines based off of screen height:

    #define HEIGHT_IPHONE_5 568
    #define IS_IPHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    #define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5)
    

    In your base controller:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        if (IS_IPHONE_5) {
            CGRect r = self.view.frame;
            r.size.height = HEIGHT_IPHONE_5 - 20;
            self.view.frame = r;
        }
        // now the view is stretched properly and not pushed to the bottom
        // it is pushed to the top instead...
    
        // other code goes here...
    }
    

提交回复
热议问题