我是obj-c编程的首发,我需要知道如何显示设备信息(名称,设备类型,ios版本)
我知道答案,请告诉我并记住我是xcode的首发;)
答案 0 :(得分:3)
我在我开发的应用程序中使用了这些信息,因此我执行了以下代码。我想这可能会对你有所帮助。我只是不明白你对设备类型的意思。
获取设备型号:
// get model from UIDevice
NSString *modelDevice = [UIDevice currentDevice].model;
获取iOS版本:
//get the iOS version
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
获取设备名称:
/** Method responsible to get the device name
*
* @return device Name
*/
+ (NSString *)deviceName
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
答案 1 :(得分:0)
请参阅UIDevice Class。它具有所有可访问的系统信息属性。这是一个单身人士班。您可以像这样访问此类实例:[UIDevice currentDevice]
例如,如果您想访问设备型号,可以这样访问:
[UIDevice currentDevice]. model
请参阅此链接以获取有关所有属性的信息:https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html
答案 2 :(得分:0)
您可以尝试这样的事情:我将此用于来自用户的应用内支持电子邮件。
#import <sys/utsname.h>
- (void)yourMethod
{
struct utsname systemInfo;
uname(&systemInfo);
NSString *appVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
NSString *machine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
答案 3 :(得分:0)
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel])
;