在iPhone应用程序中检测相机的存在?
我正在编写iOS应用程序,我需要能够检测设备是否有摄像头。以前,我会检查设备是否是iPhone,因为只有iPhone有摄像头 - 但随着iPod Touch 4的推出,这已不再是一个可行的选择。该应用程序在没有相机的情况下运行,但相机的存在增加了功能。
I'm writing an iOS app, and I need to be able to detect if the device has a camera. Previously, I would check if the device is an iPhone or not, since only the iPhone has a camera - but with the launch of the iPod Touch 4 this is no longer a viable option. The app functions without a camera, but the presence of a camera adds functionality.
那么,任何人都可以向我提供返回是否有相机的代码吗? / p>
So, can anyone provide me with code that returns whether there is a camera or not?
你可以在UIImagePickerController中使用 + isSourceTypeAvailable:
方法:
You can use +isSourceTypeAvailable:
method in UIImagePickerController:
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
// Has camera