ios - 即使 allowsEditing 为真,editingInfo 中也没有 UIImagePickerControllerEditedImage

标签 ios iphone swift uiimagepickercontroller

我正在尝试从 UIImagePickerController 获取编辑后的图像,但 editingInfo 字典中没有 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 {

    }
}

编辑信息输出

[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])!

关于ios - 即使 allowsEditing 为真,editingInfo 中也没有 UIImagePickerControllerEditedImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32266602/

相关文章:

ios - 每个 UITableView 的 UITableView 循环有不同的数据?

iOS 4.3 : How to handle the logging message: "Received memory warning. Level=1"?

ios - 如何在 iOS Swift 中使用 alamofire 获取 json 响应?

ios - 如何设置自定义距离 Filter ,在 Swift 中是否可行?

ios - 'NavigationViewController' 没有可见的@interface 声明了选择器 'initWithRootViewController:'

ios - UITableView 上的 UIKit 动态

ios - 是否可以在swift 4的代码中关闭wifi或将iPhone切换到离线模式?

ios - 在 phonegap 开发者应用程序中使用 iframe

ios - SwiftUI ForEach View 第一次未更新

ios - 在 iOS Swift 中单击按钮时向 UITableView 添加一个项目