2012-02-13 40 views

回答

-1

嘗試

[[UIDevice currentDevice] platformString] 

這將正常返回,如果它是iPhone 4S ...

+0

這不是標準UIDevice API的一部分:https://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html – yuji 2012-02-13 16:32:24

1
#import <sys/utsname.h> 

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

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

這個函數返回給我「iPhone 4.1」,而不是「iPhone 4S」有什麼理由? – user1051935 2012-02-22 18:21:29

+0

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