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

后端 未结 30 3150
醉话见心
醉话见心 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条回答
  • 2020-11-21 06:15

    I never faced such an issue with any device as I've had one codebase for all, without any hardcoded values. What I do is to have the maximum sized image as resource instead of one for each device. For example, I would have one for retina display and show it as aspect fit so it will be views as is on every device. Coming to deciding the frame of button, for instance, at run time. For this I use the % value of the patent view, example , if I want the width to be half of parent view take 50 % of parent and same applies for height and center.

    With this I don't even need the xibs.

    0 讨论(0)
  • 2020-11-21 06:15

    Rather than using a set of conditionals you can resize your view automatically using the screen size.

    int h = [[UIScreen mainScreen] bounds].size.height;
    int w = [[UIScreen mainScreen] bounds].size.width;
    self.imageView.frame = CGRectMake(20, 80, (h-200), (w-100));
    

    In my case I want a view that fills the space between some input fields at the top and some buttons at the bottom, so fixed top left corner and variable bottom right based on screen size. My app fills the image view with the photo taken by the camera so I want all the space I can get.

    0 讨论(0)
  • 2020-11-21 06:17

    I had added the new default launch image and (in checking out several other SE answers...) made sure my storyboards all auto-sized themselves and subviews but the retina 4 inches still letterboxed.

    Then I noticed that my info plist had a line item for "Launch image" set to "Default.png", which I thusly removed and magically letterboxing no longer appeared. Hopefully, that saves someone else the same craziness I endured.

    0 讨论(0)
  • 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...
    }
    
    0 讨论(0)
  • 2020-11-21 06:19

    I would suggest to use Autoresizing Mask in your applications according to your UI interface, it saves a lot of trouble and is better than making different UI for iPhone 4 and 5 screens.

    0 讨论(0)
  • 2020-11-21 06:20

    You can manually check the screen size to determine which device you're on:

    #define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568)
    
    float height = DEVICE_IS_IPHONE5?568:480;
    if (height == 568) {
        // 4"
    
    } else {
    
        // 3"
    
    }
    
    0 讨论(0)
提交回复
热议问题