01-12 IOS擷取手機與螢幕屬性

來源:互聯網
上載者:User

標籤:


在次之前,補充個內容。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 );   //手機型號

01-12 IOS擷取手機與螢幕屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.