मैं अपने अनुप्रयोग में एक कस्टम कैमरा है और यह ठीक काम किया, लेकिन नया अद्यतन के बाद मैं इस त्रुटि हो रही है:लेते हुए फोटो
'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 जहां मुझे लगता है कि त्रुटि मिल रही है चालू है: इसे काम करने के बजाय मुझे इसका क्या उपयोग करना चाहिए?
धन्यवाद।
डिफाइनिंग photoSetting कैप्चरिंग समारोह कॉल करने के लिए एक चर के रूप में मेरे लिए काम नहीं किया, क्योंकि दूसरी तस्वीर से आईबी में एक बटन बना सकते हैं लिया गया था, आवेदन मैं कह दुर्घटनाग्रस्त फोटो सेटिंग्स का उपयोग करने की अनुमति नहीं थी। AVCapturePhotoSettings को आपके आईबीएक्शन में "चलो" (var नहीं) के साथ परिभाषित किया जा सकता है या हर बार जब आप फोटो लेते हैं, तो यह बार-बार फोटो लेने के साथ ठीक काम करेगा। – VagueExplanation
हाय, @VagueExplanation, उत्तर के लिए धन्यवाद लेकिन मुझे समझ में नहीं आया कि वास्तव में दुर्घटना का कारण क्या है (हर बार जब मैं एवी कैप्चर फोटोोटोटिंग को तुरंत चालू करता हूं) लगता है। मेरे ऐप में 'फोटो बूथ' व्यू में पोस्ट किया गया कोड, मूल रूप से, आप एक फोटो ले सकते हैं और अगली बार देख सकते हैं कि आप संतुष्ट हैं या इसे फिर से लेते हैं यदि आपको यह पसंद नहीं है। तस्वीर एल्बम में सहेजी गई है और ऐप आईपैड पर चलता है। उम्मीद है कि मददगार होगा? या शायद आप चर्चा के लिए अधिक जानकारी प्रदान कर सकते हैं? –
आह ठीक है, तो कभी बुरा मत मानो। यह इस बात पर निर्भर करता है कि आप इसका उपयोग कैसे करते हैं। – VagueExplanation