现在iOS设备有0~2台摄像头。如何检测它们?
答案 0 :(得分:18)
您遍历视频设备......
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
AVCaptureDevice *captureDevice = nil;
for (AVCaptureDevice *device in videoDevices) {
if (device.position == AVCaptureDevicePositionFront) {
//FRONT-FACING CAMERA EXISTS
}
}
当然你也可以用谓词更快地做到这一点,但是我会留给你解决问题;)....(提示:在devicesWithMediaType上使用filteredArrayUsingPredicate:方法:)