ipad 2 camera support detection

别等时光非礼了梦想. 提交于 2020-02-02 05:19:07

问题


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?


回答1:


[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

That should work




回答2:


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


来源:https://stackoverflow.com/questions/5863328/ipad-2-camera-support-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!