UIImagePickerController in Swift 3
我最近使用开发人员beta更新到Xcode 8中的Swift 3。
我正在尝试实施Firebase Auth,一切进展顺利。
我的问题:
我正在尝试将图像作为用户的个人资料图片上传到Firebase数据库。
我以为可以使用
"Thread 7: Signal SIGABRT
我知道这通常会指示什么,但是我检查了一下,当我点击它时,我的图像确实打印了我的测试语句。
我失败的方法:
ViewController.swift
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import UIKit import Firebase import Photos class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate{ @IBOutlet weak var imageView: UIImageView! @IBOutlet var emailTextField: UITextField! @IBOutlet var passWordTextField: UITextField! @IBOutlet var nameTextField: UITextField! override func viewDidLoad() { super.viewDidLoad() if FIRAuth.auth()?.currentUser?.uid != nil { let storyboard = UIStoryboard(name:"Main", bundle: nil) let view = storyboard.instantiateViewController(withIdentifier:"ProfileViewController") self.present(view, animated: true, completion: nil) } imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleSelectProfileImageView))) imageView.isUserInteractionEnabled = true self.emailTextField.delegate = self; self.passWordTextField.delegate = self; self.nameTextField.delegate = self; } func handleSelectProfileImageView() { let picker = UIImagePickerController() picker.delegate = self picker.allowsEditing = true present(picker, animated: true, completion: nil) } |
我不确定这是否只是Swift 3和开发人员Xcode 8 beta的问题,还是我只是以错误的方式使用Swift 3而已。
编辑:
我使用的是xcode8的GM版本,但仍然遇到相同的错误。
我认为您需要从
1 2 3 4 5 6 7 8 | Key : Privacy - Media Library Usage Description Value : YES Key : Privacy - Photo Library Usage Description Value : YES Key : Privacy - Camara Usage Description Value : YES |
这里的值是
所以试试看
查看Apple文档以获取更多详细信息!
参考:这篇文章
遵循xCode的错误消息,然后将键/值添加到应用程序的
例如,我从正在开发的应用程序中收到一条错误消息。 它提醒我将
来自xCode的错误消息
This app has crashed because it attempted to access privacy-sensitive
data without a usage description. The app's Info.plist must contain
an NSCameraUsageDescription key with a string value explaining to the
user how the app uses this data.
和更多
将
例如,我在
1 | "NSCameraUsageDescription" ="We needs camera permission to capture image."; |