ipad 2相机支持检测

时间:2011-05-02 22:52:28

标签: iphone objective-c ipad camera

我有一个使用以下宏的应用程序:

#define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

对我来说效果很好。

但是,我正在使用它来关闭在应用中拍照的选项。

无论设备如何,我如何检测相机选项是否可用?

2 个答案:

答案 0 :(得分:12)

  

[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

那应该有用

答案 1 :(得分:2)

请参阅How to Detect Camera Existence with AVFoundation

NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
AVCaptureDevice *captureDevice = nil;

if ( [videoDevices count] > 0 ) // This device has one or more cameras
....