我正在尝试从UIImagePickerController获取编辑的图像,但是在editInfo字典中没有UIImagePickerControllerEditedImage键。怎么了?

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 {

    }
}

editInfo输出
[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]

最佳答案

您正在使用func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!),已弃用。

请改用func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])!

10-05 21:18