私は私のアプリでカスタムカメラを持って、それがうまく働いたが、私はこのエラーを取得しています新しいアップデート後:カスタムカメラiOSの11.0スウィフト4. Updateエラーで写真を撮る
'jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)' was deprecated in iOS 11.0: Use -[AVCapturePhoto fileDataRepresentation] instead.
これはラインでありますどこでそのエラーを取得しています:
guard let imageData =
AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: photoSampleBuffer, previewPhotoSampleBuffer: previewPhotoSampleBuffer) else {
return
}
これは私の全体の機能(必要な場合)である:
//Take pic function
func photoOutput(_ captureOutput: AVCapturePhotoOutput,
didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?,
previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?,
resolvedSettings: AVCaptureResolvedPhotoSettings,
bracketSettings: AVCaptureBracketedStillImageSettings?,
error: Error?) {
// Make sure we get some photo sample buffer
guard error == nil,
let photoSampleBuffer = photoSampleBuffer else {
print("Error capturing photo: \(String(describing: error))")
return
}
// Convert photo same buffer to a jpeg image data by using // AVCapturePhotoOutput
guard let imageData =
AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: photoSampleBuffer, previewPhotoSampleBuffer: previewPhotoSampleBuffer) else {
return
}
let dataProvider = CGDataProvider(data: imageData 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)
self.tempImageView.image = image
}
マイguestiをオンになっています:代わりに何を使用して機能させるべきですか?
ありがとうございます。 iOSの11で
定義写真植字上のキャプチャ機能を呼び出すためにIBのボタンを作成することができます写真の設定を使用できませんでした。 AVCapturePhotoSettingsは、あなたが写真を撮るたびにIBActionや他の機能で "let"(varではなく)で定義することができます。 – VagueExplanation
こんにちは、@VagueExplanation、返信いただきありがとうございますが、私はまさにクラッシュ(AVCapturePhotoSettingをインスタンス化するたびに聞こえるのですか?投稿されたコードは、私のアプリの「写真ブース」ビューで働いたので、基本的に写真を撮って満足している次のビューに進むことができます。写真はアルバムに保存され、アプリはiPadで動作します。それが助けになることを願っていますか?あるいは、議論の詳細を提供することができますか? –
ああ、大丈夫です。どのように使用するかによって異なります。 – VagueExplanation