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

后端 未结 30 3239
醉话见心
醉话见心 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: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;
    }
    

提交回复
热议问题