3
我想這裏的照片拍攝圖像時:隨機誤差捕捉iOS上
var stillImageOutput = AVCaptureStillImageOutput()
stillImageOutput!.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
[...]
if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo) {
videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
println("enabled = \(videoConnection.enabled)") //enabled = true
println("active = \(videoConnection.active)") //active = true
stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {
(sampleBuffer, error) in
if error != nil {
println(error)
}
})
}
它完美的大部分時間!調用captureStillImageAsynchronouslyFromConnection
當
但有時我得到一個錯誤:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn't be completed."
UserInfo=0x14682110 {NSLocalizedDescription=The operation couldn't be completed.,
NSUnderlyingError=0x1676be30 "The operation couldn't be completed.
(OSStatus error -16400.)",
NSLocalizedFailureReason=An unknown error has occured (-16400)}
我只想預計會出現此錯誤。我試着用videoConnection.enabled
和videoConnection.active
進行測試,但是兩者似乎都與錯誤無關...
在捕獲照片之前,我需要檢查以確保一切正常嗎?
也經過很多調試。我解決了這個問題:http://stackoverflow.com/a/42691502/7084347 –