Saya mencoba untuk menampilkan gambar dari perpustakaan foto di UIImageView
Kesalahan lengkapnya adalah:
09-06-2017 21: 55: 59.063307 + 0200 firstapp2.0 [12873: 1120778] Kesalahan penemuan PhotoPicker: Error Domain = PlugInKit Code = 13 "kueri dibatalkan" UserInfo = {NSLocalizedDescription = kueri dibatalkan}
Kode saya disertakan di bawah ini:
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)
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
nilai kamus dicor sebagai id di obj-c. Saya juga telah menerapkan permintaan otorisasi dan penanganan untuk mengakses perpustakaan foto pengguna: masih mendapatkan pesan kesalahan. Saya telah menambahkan di file info.plist entri privasi untuk penggunaan perpustakaan foto pengguna.