在 Swift 2.3 中,我使用以下代码来在自定义相机中拍照:
func didPressTakePhoto(){
if let videoConnection = stillImageOutput!.connection(withMediaType: AVMediaTypeVideo) {
stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: { (sampleBuffer, error) -> Void in
if sampleBuffer != nil {
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
let dataProvider = CGDataProviderCreateWithCFData(imageData)
let cgImageRef = CGImageCreateWithJPEGDataProvider(dataProvider, nil, true, CGColorRenderingIntent.RenderingIntentDefault)
let image = UIImage(CGImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.Right)
self.captureImageView.image = image
}
})
}
}
但是他的代码行:
stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: { (sampleBuffer, error) -> Void in
显示了这个错误:
类型“AVCapturePhotoOutput”的值没有成员“captureStillImageAsynchronouslyFromConnection”
我尝试解决我的问题,但是我总是遇到越来越多的错误,这就是为什么我发布原始代码的原因。
有人知道如何让我的代码再次工作吗?
谢谢。
print(image: UIIMage...)
行上,我收到一个错误Argument labels (image:) do not match any available overloads.
。 - noblerare