我知道以前有人问过这个问题,但没有一个答案能解决我的问题。我收到错误:
错误域=PlugInKit 代码=13 “查询已取消” UserInfo={NSLocalizedDescription=查询已取消}
我有另一个项目,我在另一个项目中使用这种精确的方法,效果很好。我试图将@objc 放在函数前面,但出现此错误:
imagePickerController:didFinishPickingMediaWithInfo:
方法提供的Objective-C 方法与协议中imagePickerController(_:didFinishPickingMediaWithInfo:)
的可选需求方法冲突。imagePickerController(_:didFinishPickingMediaWithInfo:)
UIImagePickerControllerDelegate
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
guard let uid = Auth.auth().currentUser?.uid else { return }
if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage {
let editImage = editedImage.withRenderingMode(.alwaysOriginal)
guard let uploadData = editImage.jpegData(compressionQuality: 0.3) else { return }
let filename = NSUUID().uuidString
let stoarageRef = Storage.storage().reference().child("profile_images").child(filename)
stoarageRef.putData(uploadData, metadata: nil) { (metadata, error) in
if let error = error {
print("Failed update profile image:", error)
}
stoarageRef.downloadURL(completion: { (downloadUrl, error) in
guard let profileImageUrl = downloadUrl?.absoluteString else { return }
print("Successfully updated image in storage:", profileImageUrl)
let dictionaryValues = ["profileImageUrl": profileImageUrl]
Database.database().reference().child("users").child(uid).updateChildValues(dictionaryValues, withCompletionBlock: { (error, ref) in
if let error = error {
print("There was an error:", error)
return
}
print("Successfully saved user info to db")
})
})
}
} else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage {
let origImage = originalImage.withRenderingMode(.alwaysOriginal)
guard let uploadData = origImage.jpegData(compressionQuality: 0.3) else { return }
let filename = NSUUID().uuidString
let stoarageRef = Storage.storage().reference().child("profile_images").child(filename)
stoarageRef.putData(uploadData, metadata: nil) { (metadata, error) in
if let error = error {
print("Failed update profile image:", error)
}
stoarageRef.downloadURL(completion: { (downloadUrl, error) in
guard let profileImageUrl = downloadUrl?.absoluteString else { return }
print("Successfully updated image in storage:", profileImageUrl)
let dictionaryValues = ["profileImageUrl": profileImageUrl]
Database.database().reference().child("users").child(uid).updateChildValues(dictionaryValues, withCompletionBlock: { (error, ref) in
if let error = error {
print("There was an error:", error)
return
}
print("Successfully saved user info to db")
})
})
}
}
dismiss(animated: true, completion: nil)
}
感谢您为解决此问题提供的任何帮助。