01-12 IOS获取手机与屏幕属性


在次之前,补充个内容。UIDevice是无法获得具体的设备型号的。

要获得设备型号,比如(iphone 4s, iphone5)这样的,要通过这样的办法。

1.引入头文件。

#include <sys/types.h>

#include <sys/sysctl.h>

2.获取型号

            //手机型号。
            size_t size;
            sysctlbyname("hw.machine", NULL, &size, NULL, 0);
            char *machine = (char*)malloc(size);
            sysctlbyname("hw.machine", machine, &size, NULL, 0);
            NSString *platform = [NSString stringWithCString:machine 
                                  encoding:NSUTF8StringEncoding];

这里得到的platform是个设备型号。  比如iphone5,2.

所以如果想更完美点,可以自己根据字符串判断。

比如: if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";

一.UIDevice

    //设备相关信息的获取  
    NSString *strName = [[UIDevice currentDevice] name];  
    NSLog(@"设备名称:%@", strName);//e.g. "My iPhone"  

    NSString *strId = [[UIDevice currentDevice] uniqueIdentifier];  
    NSLog(@"设备唯一标识:%@", strId);//UUID,5.0后不可用  
      
    NSString *strSysName = [[UIDevice currentDevice] systemName];  
    NSLog(@"系统名称:%@", strSysName);// e.g. @"iOS"  

    NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];  
    NSLog(@"系统版本号:%@", strSysVersion);// e.g. @"4.0"  
      
    NSString *strModel = [[UIDevice currentDevice] model];  
    NSLog(@"设备模式:%@", strModel);// e.g. @"iPhone", @"iPod touch"  
      
    NSString *strLocModel = [[UIDevice currentDevice] localizedModel];  
    NSLog(@"本地设备模式:%@", strLocModel);// localized version of model 
    //地方型号(国际化区域名称)  
      
    NSString* phoneModel = [[UIDevice currentDevice] model];  
    NSLog(@"手机型号: %@",phoneModel );   //手机型号
时间: 2024-08-26 07:36:57

01-12 IOS获取手机与屏幕属性的相关文章

3.IOS获取手机与屏幕属性

在次之前,补充个内容.UIDevice是无法获得具体的设备型号的. 要获得设备型号,比如(iphone 4s, iphone5)这样的,要通过这样的办法. 1.引入头文件. #include <sys/types.h> #include <sys/sysctl.h> 2.获取型号             //手机型号.             size_t size;             sysctlbyname("hw.machine", NULL, &a

IOS 获取手机ip地址

#include <ifaddrs.h> #include <arpa/inet.h> - (NSString *)getIPAddress {          NSString *address = @"error";     struct ifaddrs *interfaces = NULL;     struct ifaddrs *temp_addr = NULL;     int success = 0;          // retrieve th

iOS获取手机相关信息

iOS具体的设备型号: #include <sys/types.h> #include <sys/sysctl.h> - (void)test { //手机型号. size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = (char*)malloc(size); sysctlbyname("hw.machine", machine, &

ios 获取手机相关的信息

获取手机信息      应用程序的名称和版本号等信息都保存在mainBundle的一个字典中,用下面代码可以取出来 //获取版本号 NSDictionary *infoDict = [[NSBundle mainBundle]infoDictionary]; NSString *versionNum = [infoDict objectForKey:@"CFBundleVersion"];//版本号 NSString *appName = [infoDict objectForKey:

iOS 获取手机当前所连接的网络的IP地址

1首先要在当前所在的类导入这几个头文件: #include <arpa/inet.h>#include <netdb.h>#include <net/if.h>#include <ifaddrs.h>#import <dlfcn.h> 2具体代码的实现: //获取手机的网络的ip地址- (NSString *)getIPAddress{ BOOL success; struct ifaddrs * addrs; const struct ifad

ios获取手机状态 idfa &nbsp; idfv &nbsp; 网络类型 &nbsp; 分辨率 &nbsp; 获取运营商

//idfa [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; //idfv [[[UIDevice currentDevice] identifierForVendor] UUIDString]; //网络类型 - (NSString *) getNet { UIApplication *application = [UIApplication sharedApplication]; NSArra

iOS - 获取手机中所有图片

1 #import <AssetsLibrary/AssetsLibrary.h> 3 4 5 /** 6 * ALAssetsLibrary.h 代表资源库(所有的视频,照片) 7 ALAssetsGroup.h 代表资源库中的相册 8 ALAsset.h 代表相册中一个视频或者一张照片 9 ALAssetRepresentation.h 代表一个资源的描述,可以获取到原始图片 10 */ 11 12 @interface ViewController () 13 14 @property

IOS获取手机设备型号

最新型号的设备列表https://www.theiphonewiki.com/wiki/Models 1 #import "iosutils/IOSUtils.h" 2 #import "sys/sysctl.h" 3 #import "sys/utsname.h" 4 5 @implementation IOSUtils 6 7 + (NSString *)getCurrentDeviceModel 8 { 9 struct utsname s

iOS 获取手机的型号,系统版本,软件名称,软件版本

应用程序的名称和版本号等信息都保存在mainBundle的一个字典中,用下面代码可以取出来. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];NSString* versionNum =[infoDict objectForKey:@"CFBundleVersion"];NSString*appName =[infoDict objectForKey:@"CFBundleDisplayName&qu