0
我试图采取自定义相机视图的照片,代码不显示任何误差修改 但仍没有发生在我的ImageView ...拍照定制相机
@IBAction func photoTake(_ sender: UIButton) {
func capture(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer photoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) {
if let error = error {
print(error.localizedDescription)
}
if let sampleBuffer = photoSampleBuffer, let previewBuffer = previewPhotoSampleBuffer,
let dataImage = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: sampleBuffer, previewPhotoSampleBuffer: previewBuffer) {
let dataProvider = CGDataProvider(data: dataImage as CFData)
let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.absoluteColorimetric)
let image = UIImage(cgImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.right)
print(UIScreen.main.bounds.width)
self.capturedimage.image = image
self.capturedimage.isHidden = false
} else {
}
}
}
我从这个线程获取代码 Taking photo with custom camera Swift 3
你在另一个函数里面有一个函数,没有别的。你永远不会调用嵌套函数。 – rmaddy
是的,这是我的错 – sarko