【问题标题】:Objective-C Getting the device version [duplicate]Objective-C获取设备版本[重复]
【发布时间】:2012-03-05 01:05:53
【问题描述】:

可能重复:
Determine device (iPhone, iPod Touch) with iOS
How to check iOS version?

我正在使用这个函数来获取设备名称

NSString *device=[UIDevice currentDevice].model;

它返回我,例如,“iPhone”。

有没有办法获取设备版本,例如“iPhone 4S”。

【问题讨论】:

  • 哦,我链接到了错误的副本。

标签: objective-c xcode4.2


【解决方案1】:

试试

[[UIDevice currentDevice] platformString]

如果是 iPhone 4S 会正常返回...

【讨论】:

【解决方案2】:
#import <sys/utsname.h>

- (NSString *)deviceModel
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}

【讨论】:

  • 这个函数返回“iPhone 4.1”而不是“iPhone 4S”有什么原因吗?
  • iPhone 4.1 = iPhone 4S、iPhone 3.1 = iPhone 4、iPhone 2.1 = iPhone 3GS、iPhone 1.2 = iPhone 3G 和 iPhone 1.1 = iPhone 1G。
猜你喜欢
  • 2011-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多