I am trying to get the edited image from UIImagePickerController, but there is no UIImagePickerControllerEditedImage key in the editingInfo dictionary. What's wrong?
let pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.allowsEditing = true
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
pickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.presentViewController(pickerController, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
println(editingInfo)
if let editedImage = editingInfo[UIImagePickerControllerEditedImage] as? UIImage {
}
}
editingInfo outputs
[UIImagePickerControllerOriginalImage: <UIImage: 0x7f8f15a1f0e0> size {1500, 1001} orientation 0 scale 1.000000, UIImagePickerControllerCropRect: NSRect: {{994, 514}, {501, 487}}, UIImagePickerControllerReferenceURL: assets-library://asset/asset.JPG?id=900A4F75-A88F-4332-AAC8-2BD3A2B1514A&ext=JPG]
You're using func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!)
, which is deprecated.
Use func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])
instead!
Hope this works:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
self.imageView.image = info[UIImagePickerControllerEditedImage] as? UIImage
self.dismissViewControllerAnimated(true, completion: nil)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.