在代码中区分 iPhone4 和 iPodTouch4
我想以编程方式区分 iPhone4 和 iTouch4。这是我尝试过的:
+(BOOL) isIphone4 {
if ( ![ImagePicker isIpodTouch4] ) {
return NO;
}
if ([UIImagePickerController respondsToSelector:@selector(isFlashAvailableForCameraDevice:)]) {
if ([UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear]) {
return YES;
}
}
return NO;
}
+(BOOL) isIpodTouch4 {
if ([UIImagePickerController respondsToSelector:@selector(isCameraDeviceAvailable:)] ) {
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
return YES;
}
}
return NO;
}
不过,似乎 iPod Touch 4 也通过了 iPhone4 的测试。 有人有什么想法吗?
谢谢。
I want to programmatically differentiate between iPhone4 and iTouch4. Here is what I have tried :
+(BOOL) isIphone4 {
if ( ![ImagePicker isIpodTouch4] ) {
return NO;
}
if ([UIImagePickerController respondsToSelector:@selector(isFlashAvailableForCameraDevice:)]) {
if ([UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear]) {
return YES;
}
}
return NO;
}
+(BOOL) isIpodTouch4 {
if ([UIImagePickerController respondsToSelector:@selector(isCameraDeviceAvailable:)] ) {
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
return YES;
}
}
return NO;
}
However, seems like iPod Touch 4 is also passing the test for iPhone4.
Does anyone have any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这类似于:
使用 iPhone SDK 确定设备(iPhone、iPod Touch)< /a>
包含的代码示例可以让您知道确切的设备。
This is similar:
Determine device (iPhone, iPod Touch) with iPhone SDK
The code example included allows you to tell the exact device.