I'm getting the following error:
errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
When using simulator and selecting photo from iPhones stored library....
Can anyone see what might be the issue(s) in the code below?
import UIKit
import Firebase
class PictureViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var descriptionTextField: UITextField!
@IBOutlet weak var nextButton: UIButton!
var imagePicker = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
imagePicker.delegate = self
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
imageView.image = image
imageView.backgroundColor = UIColor.clear
imagePicker.dismiss(animated: true, completion: nil)
}
@IBAction func cameraTapped(_ sender: Any) {
imagePicker.sourceType = .savedPhotosAlbum
imagePicker.allowsEditing = false
present(imagePicker, animated: true, completion: nil)
}
@IBAction func nextTapped(_ sender: Any) {
let imagesFolder = Storage.storage().reference().child("images")
let imageData = UIImagePNGRepresentation(imageView.image!)!
imagesFolder.child("images.png").putData(imageData, metadata: nil, completion: {(metadata, error) in
print("We tried to upload!")
if error != nil {
print("We had an error:\(error)")
} else {
self.performSegue(withIdentifier: "selectUsersegue", sender: nil)
}
})
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
}
}
Try specifying the modalPresentationStyle of the view controller to .overFullScreen
@IBAction func cameraTapped(_ sender: Any) {
imagePicker.sourceType = .savedPhotosAlbum
imagePicker.allowsEditing = false
imagePicker.modalPresentationStyle = .overFullScreen
present(imagePicker, animated: true, completion: nil)
}
Don't know if it will work for you but I guess you should give it a try. One of the problems could be, that you don't have permissions to access "Photos" on your device. (if this is all of your code, it looks like I am right)
I was having similar issues few weeks ago and adding permission request solved it.
EDIT
// Authorization for Photos
let photos = PHPhotoLibrary.authorizationStatus()
if photos == .notDetermined {
PHPhotoLibrary.requestAuthorization({status in
if status == .authorized{
...
} else {}
})
}
Also make sure you add these to Info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>Description.</string>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.