gpt4 book ai didi

ios - 错误域 = PlugInKit 代码 = 13 "query cancelled"UserInfo = {NSLocalizedDescription = 查询已取消}

转载 作者:行者123 更新时间:2023-11-30 11:03:00 27 4
gpt4 key购买 nike

edit with image for privacy我遇到了这个令人沮丧的错误,而且我不知道我做错了什么,因为

make photo works

and choose from the library doesn't work

我使用的是 swift 4,我的代码如下所示:

class ProfileViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

var imagePicker = UIImagePickerController()

override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}

@objc func changeThePicture(sender: UITapGestureRecognizer) {
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertController.Style.actionSheet)
alertController.addAction(UIAlertAction(title: "Choose a photo from your gallery", style: UIAlertAction.Style.default, handler: { (action) -> Void in
self.changePicture()
}))
alertController.addAction(UIAlertAction(title: "Make a photo", style: UIAlertAction.Style.default, handler: { (action) -> Void in
self.openCamera()
}))

alertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: nil))
self.present(alertController, animated: true, completion: nil)
}

func changePicture() {
self.checkPhotoLibraryPermission {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.photoLibrary) {
self.imagePicker.allowsEditing = false
self.imagePicker.sourceType = .photoLibrary
self.imagePicker.mediaTypes = [kUTTypeImage as String]
self.present(self.imagePicker, animated: true, completion: nil)
}
}
}

func openCamera() {
self.checkMakePhotoPermission {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
self.imagePicker.allowsEditing = false
self.imagePicker.sourceType = .camera
self.imagePicker.mediaTypes = [kUTTypeImage as String]
self.present(self.imagePicker, animated: true, completion: nil)
}
}
}

@IBAction func changePictureButton(_ sender: UITapGestureRecognizer) {
self.changeThePicture(sender: sender)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
dismiss(animated: true, completion: nil)
}

@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
print("media")
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
self.chosenImage = pickedImage
userProfilePic.imageView.image = pickedImage
uploadImage(userImage: chosenImage) { (result) in
}
}
dismiss(animated:true, completion: nil)
}

media is printed only when I make a photo...but when I choose from library nothing happens I receive this error

[discovery] errors encountered while discovering extensions: ErrorDomain=PlugInKit Code=13 "query cancelled"UserInfo={NSLocalizedDescription=query cancelled}

最佳答案

您的问题是因为您在图像选择器模式完全关闭之前执行了逻辑(上传图像)。

将你的方法更改为:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
print("media")
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
dismiss(animated:true) { [weak self] in
self?.chosenImage = pickedImage
self?.userProfilePic.imageView.image = pickedImage
self?.uploadImage(userImage: chosenImage) { (result) in
}
}
} else {
dismiss(animated:true, completion: nil)
}
}

关于ios - 错误域 = PlugInKit 代码 = 13 "query cancelled"UserInfo = {NSLocalizedDescription = 查询已取消},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53079459/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com