Ios UIImagePickerController未在Swift中工作

Ios UIImagePickerController未在Swift中工作,ios,swift,uiimagepickercontroller,Ios,Swift,Uiimagepickercontroller,当我通过UIImagePickerController选择图像时,我在xCode中获得以下输出: [发现]发现扩展时遇到错误:错误域=PlugInKit代码=13查询已取消用户信息={NSLocalizedDescription=查询已取消} 这是我的代码: func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

当我通过UIImagePickerController选择图像时,我在xCode中获得以下输出:

[发现]发现扩展时遇到错误:错误域=PlugInKit代码=13查询已取消用户信息={NSLocalizedDescription=查询已取消}

这是我的代码:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    let image = info[UIImagePickerControllerOriginalImage] as! UIImage
    imagePicked = image
    
    dismiss(animated: true, completion: nil)
    performSegue(withIdentifier: "showImage", sender: self)
}
ViewController类被声明为应为:

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

let imagePickerController = UIImagePickerController()
var imagePicked = UIImage()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    imagePickerController.delegate = self

}
我使用按钮打开ImagePicker:

@IBAction func chooseImageBtn(_ sender: Any) {
    imagePickerController.sourceType = .photoLibrary
    self.present(imagePickerController, animated: true, completion: nil)
    
}
当我在模拟器中启动应用程序时,我可以单击按钮并选择一个图像,但随后选择器关闭,此消息显示在Xcode中:

2018-05-01 16:50:01.214450+0200真棒的名字[57575:12752181][MC]从私人有效用户设置读取

2018-05-01 16:50:03.740711+0200 Awesome Name[57575:12752241][discovery]发现扩展时遇到错误:Error Domain=PlugInKit Code=13 query cancelled UserInfo={NSLocalizedDescription=query cancelled}

我已经做了一些研究,但什么都没用。ImagePicker的委托被设置为self,我还尝试在func imagePickerController_picker之前添加@objc:但这并没有解决问题


我还可以尝试显示所选图像吗?

尝试删除PerformeSgue功能,如果您真的需要使用它,只需在完成Disclose功能时添加它。

您是否使用PHPhotoLibrary.requestAuthorization请求了照片库的权限?@Kamran我已将具有值的隐私-照片库使用说明密钥添加到我的info.plies中,但在访问授权之前,您还必须调用授权。您可以在这里查看如何操作我实现了requestAuthorization方法,它现在请求访问照片。单击“确定”后,ImagePicker再次打开,结果仍然与我的问题中的结果相同,并且没有发生任何事情