我收到以下错误:error Domain = PlugInKit Code = 13“查询已取消” UserInfo = {NSLocalizedDescription =查询已取消}

时间:2019-06-29 21:49:02

标签: swift firebase firebase-storage

在我的应用程序的注册页面中添加了个人资料图片选项后,我得到以下错误:发现扩展名时遇到的错误:错误域= PlugInKit代码= 13“查询已取消” UserInfo = {NSLocalizedDescription =查询已取消}。我不确定为什么会发生这种情况(我尝试了具有该错误的线程中的每条建议;但是,它们没有解决问题,并且该错误仍在显示)。

我尝试了带有该错误的线程的所有建议;但是,他们没有解决问题,并且错误仍然显示。

override func viewDidLoad() {
            super.viewDidLoad()
            let imageTap = UITapGestureRecognizer(target: self, action: #selector(openImagePicker))
            profileImageView.isUserInteractionEnabled = true
            profileImageView.addGestureRecognizer(imageTap)
            profileImageView.layer.cornerRadius = profileImageView.bounds.height / 2
            profileImageView.clipsToBounds = true
            tapToChangeProfileButton.addTarget(self, action: #selector(openImagePicker), for: .touchUpInside)

            imagePicker = UIImagePickerController()
            imagePicker.allowsEditing = true
            imagePicker.sourceType = .photoLibrary
            imagePicker.delegate = self
        }

        @objc func openImagePicker(_ sender:Any) {
            // Open Image Picker
            self.present(imagePicker, animated: true, completion: nil)
        }

        @objc func handleSignUp() {

            Auth.auth().createUser(withEmail: email, password: pass) { user, error in
                if error == nil && user != nil {
                    print("User created!")

                    self.uploadProfileImage(image) { url in

                        if url != nil {
                            let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
                            changeRequest?.displayName = username
                            changeRequest?.photoURL = url

       changeRequest?.commitChanges { error in
                                if error == nil {
                                    print("User display name is changed!")


                                    self.saveProfile(username: username, profileImageURL: url!) { success in

                                        if success {
                                            self.dismiss(animated: true, completion: nil)
                                            print("successfully uploaded")
                                        }

                                    }

                                    //     self.dismiss(animated: false, completion: nil)
                                } else {
                                    print("Error: \(error!.localizedDescription)")
                                    print("fail 1")

                                }

                            }
                        } else{


                            print("fail 2")
                        }

                    }



    } else {
                print("Error: \(error!.localizedDescription)")
                    print("fail 3")
        }

      }
    }

        func uploadProfileImage(_ image:UIImage, completion: @escaping ((_ url:URL?)->())){
            guard let uid = Auth.auth().currentUser?.uid else { return }
            let storageRef = Storage.storage().reference().child("user/\(uid)")

            guard let imageData = image.jpegData(compressionQuality: 0.75) else { return }

            let metaData = StorageMetadata()
            metaData.contentType = "image/jpg"
            storageRef.putData(imageData, metadata: metaData){ metaData, error in

                if error == nil, metaData != nil {
                    storageRef.downloadURL { url, error in
                        completion(url)
                    }
                } else {

                    completion(nil)
                    print("fail 4")
                }


             }
       }
}

    extension SignUpViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {

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

        func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

            if let pickedImage = info[.editedImage] as? UIImage{
                 self.profileImageView.contentMode = .scaleAspectFit
                 self.profileImageView.image = pickedImage
            }

            picker.dismiss(animated: true, completion: nil)
        }
    }

显示以下错误消息错误域= PlugInKit代码= 13“查询已取消” UserInfo = {NSLocalizedDescription =查询已取消}。

0 个答案:

没有答案