现在,iOS设备具有0〜2个摄像头。如何检测到它们?
最佳答案
您遍历视频设备...
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
AVCaptureDevice *captureDevice = nil;
for (AVCaptureDevice *device in videoDevices) {
if (device.position == AVCaptureDevicePositionFront) {
//FRONT-FACING CAMERA EXISTS
}
}
当然,您也可以使用谓词更快地完成此操作,但我将其留给您解决;)....(提示:在devicesWithMediaType上使用filteredArrayUsingPredicate:方法)