*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< Ctrl 0x796991d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key UIImagePickerControllerReferenceURL.'
@IBAction func btnReviewAction(sender : UIButton) {
imagePicker.delegate = self
imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary)!
imagePicker.modalPresentationStyle = UIModalPresentationStyle.popover
imagePicker.preferredContentSize = CGSize(width: 1000, height: 400)
imagePicker.allowsEditing = false
imagePicker.isEditing = false
appDel!.navController?.present(imagePicker, animated: true, completion: nil)
imagePicker.popoverPresentationController?.sourceView = sender
imagePicker.popoverPresentationController?.sourceRect = CGRect(x: 0, y: 0, width: sender.frame.size.width, height: sender.frame.size.height)
isCaptureImage = false
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
var mediaType: String = ""
mediaType = info[UIImagePickerControllerMediaType] as! String
if (mediaType == (kUTTypeImage as String)) {
if isCaptureImage == false {
let library = ALAssetsLibrary()
library.asset(for: value(forKey: UIImagePickerControllerReferenceURL) as! URL!, resultBlock: { (asset) -> Void in
let original: ALAssetRepresentation? = asset?.defaultRepresentation()
let myimag = UIImage(cgImage: original?.fullScreenImage() as! CGImage, scale: CGFloat((original?.scale())! as Float), orientation: UIImageOrientation(rawValue: 0)!)
self.imageAddView.image = self.resizeImage(image: myimag, newWidth: 600)
}, failureBlock: { (error) -> Void in
print("Failed to load captured image.")
})
picker.dismiss(animated: true, completion: { _ in })
}
}
}
Here I want to redirect PhotoGallery. and set Image on UIImmage, but I got error link above.
library.asset(for: value(forKey: UIImagePickerControllerReferenceURL)this line is causing the problem. The error description says it all:UIImagePickerControllerReferenceURLis not observable. - dirtydaneevalue(forKey: UIImagePickerControllerReferenceURL)withinfo[UIImagePickerControllerReferenceURL]? - Larme