Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipad 2 camera support detection

I have an app that uses the following Macro:

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

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?

like image 815
Mark Avatar asked Dec 10 '22 09:12

Mark


2 Answers

[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

That should work

like image 171
Joshua Weinberg Avatar answered Dec 21 '22 05:12

Joshua Weinberg


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
....
like image 24
Julio Gorgé Avatar answered Dec 21 '22 06:12

Julio Gorgé