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

后端 未结 30 3149
醉话见心
醉话见心 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:04

    Checking bounds with 568 will fail in landscape mode. iPhone 5 launches only in portrait mode but if you want to support rotations then the iPhone 5 "check" will need to handle this scenario as well.

    Here's a macro which handles orientation state:

    #define IS_IPHONE_5 (CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size, CGSizeMake(640, 1136)))
    

    The use of the 'preferredMode' call is from another posting I read a few hours ago so I did not come up with this idea.

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

    To determine if your app can support iPhone 5 Retina use this: (This could be more robust to return the type of display, 4S Retina, etc., but as it is written below, it just returns if the iPhone supports iOS5 Retina as a YES or NO)

    In a common ".h" file add:

    BOOL IS_IPHONE5_RETINA(void);
    

    In a common ".m" file add:

    BOOL IS_IPHONE5_RETINA(void) {
        BOOL isiPhone5Retina = NO;
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
            if ([UIScreen mainScreen].scale == 2.0f) {
                CGSize result = [[UIScreen mainScreen] bounds].size;
                CGFloat scale = [UIScreen mainScreen].scale;
                result = CGSizeMake(result.width * scale, result.height * scale);
    
                if(result.height == 960){
                    //NSLog(@"iPhone 4, 4s Retina Resolution");
                }
                if(result.height == 1136){
                    //NSLog(@"iPhone 5 Resolution");
                    isiPhone5Retina = YES;
                }
            } else {
                //NSLog(@"iPhone Standard Resolution");
            }
        }
        return isiPhone5Retina;
    }
    
    0 讨论(0)
  • 2020-11-21 06:10
    1. Download and install latest version of Xcode.
    2. 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.
    3. 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.
    4. If you didn't, adjust your view layouts, preferably with Auto Layout.
    5. 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.
    0 讨论(0)
  • 2020-11-21 06:10

    Use the Auto Layout feature for views. It will adjust automatically to all resolutions.

    Create two xibs for a controller having controller name with suffix either ~iphone or ~ipad. At compile time, Xcode will take the right xib based on the device.

    Use size classes, if you want to create a single xib for both iPhone and iPad, if the view is simple enough to port to iPhone and iPad.

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

    In a constants.h file you can add these define statements:

     #define IS_IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
     #define IS_IPHONE UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone
     #define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double)568) < DBL_EPSILON) 
     #define IS_IPHONE_5 (!IS_IPAD && IS_WIDESCREEN)
    
    0 讨论(0)
  • 2020-11-21 06:11

    Try the below method in a singleton class:

    -(NSString *)typeOfDevice
        {
            if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
            {
                CGSize result = [[UIScreen mainScreen] bounds].size;
                if(result.height == 480)
                {
                    return @"Iphone";
                }
                if(result.height == 568)
                {
                    return @"Iphone 5";
                }
            }
            else{
                return @"Ipad";;
            }
    
    
            return @"Iphone";
        }
    
    0 讨论(0)
提交回复
热议问题