標籤:
在次之前,補充個內容。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擷取手機與螢幕屬性