2017-01-06 67 views
0

我想能夠使用自定義相機,並將代碼從swift 2轉換爲swift 3;我非常完整;但我收到有關設備的這個錯誤;我想有一個後部和前置攝像頭和前迅速2,你會設置像這樣的設備:AV基金會與相機問題

let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as! [AVCaptureDevice] 

我現在使用的是什麼Xcode是告訴我使用的是:

let devices = AVCaptureDeviceDiscoverySession(deviceTypes: [AVCaptureDevice], mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition) 

但我得到這個錯誤

cannot convert value of type 'AVCaptureDevice.type' to expected argument type '[AVCaptureDeviceType]' 

回答

1

對於deviceTypes參數,你需要在一個或多個AVCaptureDeviceType的數組來傳遞。你的選擇是:

  • builtInMicrophone
  • builtInWideAngleCamera
  • builtInTelephotoCamera
  • builtInDualCamera

關於這些常數的詳細信息,請參閱here

雖這麼說,你可能尋找的東西,如:

let devices = AVCaptureDeviceDiscoverySession(deviceTypes: [AVCaptureDeviceType.builtInWideAngleCamera, AVCaptureDeviceType.builtInTelephotoCamera], mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.unspecified)