Я пытаюсь получить этот рабочий код, который получает UIImage с помощью selectedImage из ImagePicker и сохраняет его с помощью метода savePhoto, чтобы ТАКЖЕ получить мне метаданные UImage:
ОригиналКод:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]){
if let selectedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
//Successfully got the image, now upload it
//Get a reference to the camera view controller and call the savePhoto method
let cameraVC = self.selectedViewController as? CameraViewController
if let cameraVC = cameraVC {
cameraVC.savePhoto(image: selectedImage)
}
//Dismiss the picker
picker.dismiss(animated: true, completion: nil)
}
}
Это то, что я пытался, но thisAsset всегда возвращается ноль, поэтому он пропускает практически весь метод.
Код, который я пробовал:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]){
var arrImageIdentifiers = String()
if let thisAsset:PHAsset = info[UIImagePickerController.InfoKey.phAsset] as? PHAsset {
arrImageIdentifiers.append(thisAsset.localIdentifier)
//Get a reference to the camera view controller and call the savePhoto method
let cameraVC = self.selectedViewController as? CameraViewController
let manager = PHImageManager.default()
manager.requestImage(for: thisAsset, targetSize: CGSize(width: 300.0, height: 300.0), contentMode: .aspectFit, options: nil, resultHandler: {(thisImage, _) in
if let cameraVC = cameraVC {
cameraVC.savePhoto(image: thisImage!)
}
})
}
self.dismiss(animated: true, completion: nil)
}}
Какой самый простой способ получить метаданные фотографии (creationDate, location и т. Д.) Из исходного кода выше?