将“cameraDevice”改为后方和前方(UIImagePickerController旁边)

时间:2013-10-07 05:08:02

标签: objective-c uiimagepickercontroller

是否有任何其他API可以提供更改" cameraDevice"后方和前方? 旁边" UIImagePickerController"的cameraDevice属性?

1 个答案:

答案 0 :(得分:0)

这个功能让我解决了这个问题。

- (AVCaptureDevice *)frontFacingCamera
{
    NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
    AVCaptureDevice *captureDevice = nil;
    for (AVCaptureDevice *device in videoDevices)
    {
        if (device.position == AVCaptureDevicePositionFront) {
            captureDevice = device;
            break;
        }
    }
    return captureDevice;
}