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