可能重复:
Determine device (iPhone, iPod Touch) with iPhone SDK
Check iPhone iOS Version目标C获取设备版本
我使用这个功能N来获得设备名称
NSString *device=[UIDevice currentDevice].model;
它返回我例如“iPhone”。
是否有获取设备版本的方法,例如“iPhone 4S”。
感谢
可能重复:
Determine device (iPhone, iPod Touch) with iPhone SDK
Check iPhone iOS Version目标C获取设备版本
我使用这个功能N来获得设备名称
NSString *device=[UIDevice currentDevice].model;
它返回我例如“iPhone”。
是否有获取设备版本的方法,例如“iPhone 4S”。
感谢
尝试
[[UIDevice currentDevice] platformString]
这将正常返回,如果它是iPhone 4S ...
这不是标准UIDevice API的一部分:https://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html – yuji 2012-02-13 16:32:24
#import <sys/utsname.h>
- (NSString *)deviceModel
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
这个函数返回给我“iPhone 4.1”,而不是“iPhone 4S”有什么理由? – user1051935 2012-02-22 18:21:29
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。 – jonathananesand 2012-02-26 08:30:27
哦,我挂了错误的重复。 – 2012-02-13 16:22:42