如何只允许iPhone 4使用应用程序,因为它使用前置摄像头

Sum*_*Sum 3 iphone xcode camera

我想知道如何只让iPhone 4使用我的使用前置摄像头的应用程序.我可以做一个 + (BOOL)isCameraDeviceAvailable:(UIImagePickerControllerCameraDevice) ,如何实现它,如果它返回no,它会给出某种错误

或者我必须使用NSString*DeviceType等.

如果iPhone 4 ......什么都不做

if else ...显示提醒?

如何在我的应用程序中实现它?

TIA!

kso*_*rom 9

你可以添加front-facing-cameraUIRequiredDeviceCapabilities你的Info.plist.这样,如果没有前置摄像头,应用程序将无法运行,如果没有iPhone 4,您的用户将无法从App Store下载.


Sam*_*lan 5

把它放在你的app delegate的applicationDidFinishLaunching方法中:

if (![UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront])
{
     [[[[UIAlertView alloc] initWithTitle: @"No Front Camera" 
                                  message: @"This app requires a front camera." 
                                 delegate: self 
                        cancelButtonTitle: @"Ok" 
                        otherButtonTitles: nil] autorelease] show];
}
Run Code Online (Sandbox Code Playgroud)