3.IOS get phone with screen properties

Source: Internet
Author: User

Before the second, add a content. Uidevice is not available for specific device models.

To get the device model, such as (iphone 4s, iphone5), this way.

1. Introduce the header file.

#include <sys/types.h>

#include <sys/sysctl.h>

< Span style= "FONT-SIZE:18PX; Color:rgb (255, 0, 0); " >2. Get model

             //phone model.             size_t size;             sysctlbyname ("Hw.machine",  NULL, &size, &NBSP;NULL,&NBSP;0);             char *machine  =  (char*) malloc (size);             Sysctlbyname ("Hw.machine",  machine, &size, null, 0);             nsstring *platform = [nsstring stringwithcstring : machine encoding:nsutf8stringencoding]; 


here to get the  platform is a device model. Like iphone5,2.

So if you want to be more perfect, you can judge by the string yourself.

For example: if ([Platform isequaltostring:@ "iphone3,1"]) return @ "IPhone 4";


Acquisition of information about     //equipment       nsstring *strname = [[ Uidevice currentdevice] name];      nslog (@ "Device name:%@",  strName);// e.g.  "My iphone"       nsstring *strid = [[uidevice  currentdevice] uniqueidentifier];      nslog (@ "Device unique ID:%@",  strId ); not available after//uuid,5.0             nsstring * strsysname = [[uidevice currentdevice] systemname];       NSLog (@ "system name:%@",  strsysname);// e.g. @ "IOS"       nsstring * strsysversion = [[uidevice currentdevice] systemversion];       nslog (@ "System version number:%@",  strsysversion);// e.g. @ "4.0"               nsstring *strmodel = [[uidevice currentdevice] model];       nslog (@ "Device mode:%@",  strmodel),// e.g. @ "IPhone",  @ "Ipod touch"              NSString *strLocModel = [[UIDevice  Currentdevice] localizedmodel];      nslog (@ "Local device mode:%@",  strLocModel) ;// localized version of model //local model    (internationalized region name)              NSString* phoneModel = [[UIDevice  Currentdevice] model];      nslog (@ "Phone model:  %@",phoneModel );    //Phone Model


3.IOS get phone with screen properties

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.