开发者

ipad 2 camera support detection

开发者 https://www.devze.com 2023-03-02 14:54 出处:网络
I have an app that uses the following Macro: #define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == U

I have an app that uses the following Macro:

#define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserI开发者_如何学编程nterfaceIdiomPad)

which works very well for me.

However, I was using it to turn off the option of taking a photo in the app.

How can I detect if the camera option is available regardless of device?


[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

That should work


See 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
....
0

精彩评论

暂无评论...
验证码 换一张
取 消