我正在尝试在 UIImageView 中显示照片库中的图像
完整的错误是:
2017-06-09 21:55:59.063307+0200 firstapp2.0[12873:1120778] PhotoPicker 发现错误:错误域=PlugInKit 代码=13“查询已取消”用户信息={NSLocalizedDescription=查询已取消}
我的代码包括在下面:
import UIKit
class ViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate{
@IBOutlet weak var pic: UIImageView!
@IBOutlet weak var text: UILabel!
var chosenImage : UIImage!
override func viewDidLoad() {
super.viewDidLoad()
pic.isUserInteractionEnabled = true;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [AnyHashable: Any]) {
var chosenImage = info[UIImagePickerControllerEditedImage]
self.pic!.image = chosenImage as! UIImage
picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
@IBAction func tap(_ sender: Any) {
self.text.text = "Kreason"
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
imagePicker.allowsEditing = false
self.present(imagePicker, animated: true, completion: nil)
}
}