2011-08-17 45 views
0

其实我可以检测iOS版本,但是可以在iOS内检测iPhone 3G或3GS型号?在iOS中检测iPhone 3G

谢谢

+0

可能重复的HTTP ://stackoverflow.com/questions/1543925/how-do-i-detect-whether-i-have-iphone-2g-3g-3gs) –

+0

检查你需要的功能(例如:视频,电话,指南针,陀螺仪等)而不是检查特定的型号。 – progrmr

回答

1

你可以找到使用this post(我想这也是一个重复的问题)的确切型号字符串:

#include <sys/types.h> 
#include <sys/sysctl.h> 

@implementation UIDevice (Hardware) 

/* 
Platforms 
iPhone1,1 -> iPhone 1G 
iPhone1,2 -> iPhone 3G 
iPod1,1 -> iPod touch 1G 
iPod2,1 -> iPod touch 2G 
*/ 

-(NSString *) platform 
{ 
    size_t size; 
    sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
    char *machine = malloc(size); 
    sysctlbyname("hw.machine", machine, &size, NULL, 0); 
    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; 
    free(machine); 
return platform; 
} 
的[我怎样检测自己是否有iPhone 2G,3G,3GS(
3

您需要检查设备功能。 3g不支持录像机,3g不支持前置摄像头。 看看this的问题。