iOS Judging Models

Source: Internet
Author: User

 #import <foundation/foundation.h> #import <uikit/uikit.h>typedef NS _options (nsinteger,devicetype) {iphonefivepointfiveinch = 1 << 0, Iphonefourpointseveninch = 1 << 1, Iphonefourinch = 1 << 2, Iphonethreepointfiveinch = 1 << 3, Ipadpro = 1 << 4, Ipadohter = 1 << 5}; @interface checkdevice:nsobject+ (DeviceType) getcurrentdevice; @end     
#import"CheckDevice.h"#import"Sys/utsname.h"@implementationCheckdevice+ (DeviceType) Getcurrentdevice {Size of the modelIpadpro and IPhone6 Public {375, 667},ipad other models and iphone4s public {320, 480}Nsarray *iphonesize = @[@ "{414, 736}",@ "{375, 667}",@ "{320, 568}",@ "{320, 480}"];Judging screen SizeNSString *type =Nsstringfromcgsize ([UIScreen Mainscreen]. Bounds. size);struct Utsname systemInfo; Uname (&systeminfo);NSString *platform = [nsstring stringwithcstring:systeminfo.machine encoding:< Span class= "hljs-built_in" >nsutf8stringencoding]; if ([Platform Hasprefix:@ "IPhone"]) { return [iphonesize Indexofobject:type];} else if ([Platform Hasprefix:@ " IPad "]) {//ipad if ([iphonesize indexofobject:type] = = Iphonefourpointseveninch) return Ipadpro; else return Ipadohter;} else//simulator return [iPhoneSize Indexofobject:type];}  @end             



iOS Judging Models

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.