可能性の重複:
Determine device (iPhone, iPod Touch) with iPhone SDK
iPad 2 detection個別に実行時にiPadの1とiPad 2を特定する方法
本当の実行時のiPadとiPad 2を検出する方法で私を導いてください。私は両方の携帯電話に性能の問題のために異なる画像をロードしたい。事前に
おかげ
可能性の重複:
Determine device (iPhone, iPod Touch) with iPhone SDK
iPad 2 detection個別に実行時にiPadの1とiPad 2を特定する方法
本当の実行時のiPadとiPad 2を検出する方法で私を導いてください。私は両方の携帯電話に性能の問題のために異なる画像をロードしたい。事前に
おかげ
- (NSString *)machine {
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;
}
最も簡単かつ最短の方法は、チェックすることで、 "iPad2,1" @前記のようにカメラについては、iPad 2 detection:
BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
[UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);
さらに簡単には: BOOL isiPad2 = [[self platform] isEqualToString:@"iPad2,1"];
文字列はiPad2,2
とiPad2,3
でもよいことに注意してください。
ちょっとエミール、ありがとう、トン.... – user1088267
ありがとうNiko ..それは動作しますが、どこかでiPad 2、iPad2,2、またはiPad2,3(オペレータに依存)を取得できます。どのような種類の異なる文字列がiPadとiPad 2のためにチェックする必要がありますか – user1088267
これがそうであれば、iPad2のx文字列をチェックすることができます:NSRange range = [theMachineString rangeOfString:@ "iPad2" options:(NSAnchoredSearch | NSCaseInsensitiveSearch ]]; if(range.length> 0){NSLog(@ "Im a an iPad2");} – Niko