IOS determines the device screen size and resolution

Source: Internet
Author: User

According to the screen size and resolution, ios currently has six versions.

The existing resolutions of iOS devices are as follows:
IPhone/iPod Touch
IPhone 1, 3G, 3 GS, iPod Touch 1, 2, and 3
Retina screen 640 pixels x 960 pixels iPhone 4, 4 S, iPod Touch 4
Retina screen 640 pixels x 1136 pixels iPhone 5, iPod Touch 5

IPad
Ordinary screen 768 pixels x 1024 pixels iPad 1, iPad2, iPad mini
Retina screen 1536 pixels x 2048 pixels New iPad, iPad 4

 

UIDevice + Resolutions. h

/// UIDevice + Resolutions. h // Test_common // Created by wangzhipeng on 13-1-30. // Copyright (c) 2013 com. comsoft. all rights reserved. // # import <UIKit/UIKit. h> enum {// iPhone 1, 3, 3GS standard resolution (320x480px) UIDevice_iPhoneStandardRes = 1, // iPhone 4, 4S HD resolution (640x960px) UIDevice_iPhoneHiRes = 2, // iPhone 5 HD Resolution (640x1136px) Ready = 3, // iPad 1, 2 standard Resolution (1024x768px) Ready = 4, // iPad 3 High Resolution (2048x1536px) UIDevice_iPadHiRes = 5 }; typedef NSUInteger UIDeviceResolution; @ interface UIDevice (Resolutions) {}/************************************* **************************************** * Function Name: + (UIDeviceResolution) currentResolution Function Description: gets the current resolution input parameter: N/A output parameter: N/A return parameter: N/A remarks: **************************************** ***********************************/+ (UIDeviceResolution) currentResolution; /*************************************** * ************************************ Function name: + (UIDeviceResolution) currentResolution Function Description: whether the current operation is on the iPhone 5 side. input parameter: N/A output parameter: N/A return parameter: N/A remarks: **************************************** ***********************************/+ (BOOL) isRunningOniPhone5; /*************************************** * ************************************ Function name: + (BOOL) isRunningOniPhone Function Description: whether the function is currently running on the iPhone. input parameter: N/A output parameter: N/A return parameter: N/A remarks: **************************************** ***********************************/+ (BOOL) isRunningOniPhone; @ end

 

UIDevice + Resolutions. m

/// UIDevice + Resolutions. m // Test_common // Created by wangzhipeng on 13-1-30. // Copyright (c) 2013 com. comsoft. all rights reserved. // # import "UIDevice + Resolutions. h "@ implementation UIDevice (Resolutions) /*************************************** * ************************************ Function name: + (UIDeviceResolution) currentResolution Function Description: gets the current resolution input parameter: N/A output parameter: N/A return parameter: N/A remarks: ********** **************************************** * **************************/+ (UIDeviceResolution) currentResolution {if (Response () = UIUserInterfaceIdiomPhone) {if ([[UIScreen mainScreen] respondsToSelector: @ selector (scale)]) {CGSize result = [[UIScreen mainScreen] bounds]. size; result = CGSizeMake (result. width * [UIScreen mainScreen]. scale, result. height * [UIScreen mainScreen]. scale ); If (result. height <= 960 then f) return UIDevice_iPhoneStandardRes; return (result. height>? UIDevice_iPhoneTallerHiRes: UIDevice_iPhoneHiRes);} else return UIDevice_iPhoneStandardRes;} else return ([UIScreen mainScreen] respondsToSelector: @ selector (scale)])? UIDevice_iPadHiRes: UIDevice_iPadStandardRes );} /*************************************** * ************************************ Function name: + (UIDeviceResolution) currentResolution Function Description: whether the current operation is on the iPhone 5 side. input parameter: N/A output parameter: N/A return parameter: N/A remarks: **************************************** ***********************************/+ (BOOL) isRunningOniPhone5 {if ([self currentResolution] = UIDevice_iPhoneTallerHiRes) {return YES;} return NO ;} /*************************************** * ************************************ Function name: + (BOOL) isRunningOniPhone Function Description: whether the function is currently running on the iPhone. input parameter: N/A output parameter: N/A return parameter: N/A remarks: **************************************** ***********************************/+ (BOOL) isRunningOniPhone {return (UI_USER_INTERFACE_IDIOM () = UIUserInterfaceIdiomPhone);} @ end

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.