如何在iOS上检测和显示设备信息

如何在iOS上检测和显示设备信息,ios,cocoa-touch,Ios,Cocoa Touch,我是obj-c编程的初学者,我需要知道如何显示设备信息(名称、设备类型、ios版本) 我知道答案,请告诉我并记住我是xcode的初学者;) 请参考UIDevice类别。它具有所有可访问的系统信息属性。这是一个单身班。您可以如下方式访问此类实例:[UIDevice currentDevice] 例如,如果要访问设备型号,可以按如下方式访问: [UIDevice currentDevice]. model 请参阅此链接以获取有关所有属性的信息:请参阅UIDevice类。它具有所有可访问的系统信息属

我是obj-c编程的初学者,我需要知道如何显示设备信息(名称、设备类型、ios版本)


我知道答案,请告诉我并记住我是xcode的初学者;)

请参考UIDevice类别。它具有所有可访问的系统信息属性。这是一个单身班。您可以如下方式访问此类实例:
[UIDevice currentDevice]

例如,如果要访问设备型号,可以按如下方式访问:

[UIDevice currentDevice]. model

请参阅此链接以获取有关所有属性的信息:

请参阅UIDevice类。它具有所有可访问的系统信息属性。这是一个单身班。您可以如下方式访问此类实例:
[UIDevice currentDevice]

例如,如果要访问设备型号,可以按如下方式访问:

[UIDevice currentDevice]. model

请参阅此链接以获取有关所有属性的信息:

请参阅UIDevice类。它具有所有可访问的系统信息属性。这是一个单身班。您可以如下方式访问此类实例:
[UIDevice currentDevice]

例如,如果要访问设备型号,可以按如下方式访问:

[UIDevice currentDevice]. model

请参阅此链接以获取有关所有属性的信息:

请参阅UIDevice类。它具有所有可访问的系统信息属性。这是一个单身班。您可以如下方式访问此类实例:
[UIDevice currentDevice]

例如,如果要访问设备型号,可以按如下方式访问:

[UIDevice currentDevice]. model

请参阅此链接以获取有关所有属性的信息:

我在开发的应用程序中使用了这些信息,因此我编写了以下代码。我想这可能对你有帮助。我只是不明白你说的设备类型是什么意思

要获取设备型号,请执行以下操作:

// 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;
}

我在我开发的一个应用程序中使用了这些信息,所以我编写了以下代码。我想这可能对你有帮助。我只是不明白你说的设备类型是什么意思

要获取设备型号,请执行以下操作:

// 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;
}

我在我开发的一个应用程序中使用了这些信息,所以我编写了以下代码。我想这可能对你有帮助。我只是不明白你说的设备类型是什么意思

要获取设备型号,请执行以下操作:

// 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;
}

我在我开发的一个应用程序中使用了这些信息,所以我编写了以下代码。我想这可能对你有帮助。我只是不明白你说的设备类型是什么意思

要获取设备型号,请执行以下操作:

// 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;
}

您可以尝试这样的方式:我使用它来向用户发送应用内支持电子邮件

#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];
}
#导入
-(无效)你的方法
{
结构utsname系统信息;
uname(&systemInfo);
NSString*appVersion=[NSBundle mainBundle].infoDictionary[@“CbundLeverVersion”];
NSString*osVersion=[[UIDevice currentDevice]systemVersion];
NSString*machine=[NSString stringWithCString:systemInfo.machine编码:NSUTF8StringEncoding];
}

您可以尝试这样的方法:我使用它向用户发送应用内支持电子邮件

#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];
}
#导入
-(无效)你的方法
{
结构utsname系统信息;
uname(&systemInfo);
NSString*appVersion=[NSBundle mainBundle].infoDictionary[@“CbundLeverVersion”];
NSString*osVersion=[[UIDevice currentDevice]systemVersion];
NSString*machine=[NSString stringWithCString:systemInfo.machine编码:NSUTF8StringEncoding];
}

您可以尝试这样的方法:我使用它向用户发送应用内支持电子邮件

#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];
}
#导入
-(无效)你的方法
{
结构utsname系统信息;
uname(&systemInfo);
NSString*appVersion=[NSBundle mainBundle].infoDictionary[@“CbundLeverVersion”];
NSString*osVersion=[[UIDevice currentDevice]systemVersion];
NSString*machine=[NSString stringWithCString:systemInfo.machine编码:NSUTF8StringEncoding];
}

您可以尝试这样的方法:我使用它向用户发送应用内支持电子邮件

#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];
}
#导入
-(无效)你的方法
{
结构utsname系统信息;
uname(&systemInfo);
NSString*appVersion=[NSBundle mainBundle].infoDictionary[@“CbundLeverVersion”];
NSString*osVersion=[[UIDevice currentDevice]systemVersion];
NSString*machine=[NSString stringWithCString:systemInfo.machine编码:NSUTF8StringEncoding];
}

遵循此链接进行设备检测遵循此链接进行设备检测遵循此链接进行设备检测遵循此链接进行设备检测设备类型为Ipod touch、ipad、iphone,非常感谢!)我需要在appdelegate.h或.m上插入此代码?您可以创建一个类来使用此代码,也可以在需要的地方插入它。然后只需调用该方法即可获得所需信息。设备类型为Ipod touch、ipad、iphone,非常感谢!)我需要在appdelegate.h或.m上插入此代码?您可以创建一个类来使用此代码,也可以在需要的地方插入它。然后只需调用该方法即可获得所需信息。设备类型为Ipod touch、ipad、iphone,非常感谢!)我需要在appdelegate.h或.m上插入此代码?您可以创建一个类来使用此代码,也可以在需要的地方插入它。然后只需调用该方法即可获得所需信息。设备类型为Ipod touch、ipad、iphone,非常感谢!)我需要在appdelegate.h或.m上插入此代码?您可以创建一个类来使用此代码,也可以在需要的地方插入它。然后只需调用该方法即可获得所需的信息。