亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PhotoPicker發現錯誤:Error Domain = PlugInKit Code = 13

PhotoPicker發現錯誤:Error Domain = PlugInKit Code = 13

江戶川亂折騰 2019-12-13 10:16:54
我正在嘗試在UIImageView中顯示照片庫中的圖像完整的錯誤是:2017-06-09 21:55:59.063307 + 0200 firstapp2.0 [12873:1120778] PhotoPicker發現錯誤:Error Domain = PlugInKit Code = 13“查詢已取消” UserInfo = {NSLocalizedDescription =查詢已取消}我的代碼如下:import UIKitclass 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)    }}
查看完整描述

3 回答

?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

您需要明確的Objective-C參考: @objc


@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage

    image = chosenImage

    self.performSegue(withIdentifier: "ShowEditView", sender: self)

    dismiss(animated: true, completion: nil)

}


查看完整回答
反對 回復 2019-12-13
?
倚天杖

TA貢獻1828條經驗 獲得超3個贊

我找到了解決方案。由于以下兩個原因,導致出現此錯誤。


首先,我們需要調用此方法進行授權

授權碼


func checkPermission() {

  let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus() switch photoAuthorizationStatus {

    case .authorized: print("Access is granted by user")

    case .notDetermined: PHPhotoLibrary.requestAuthorization({

      (newStatus) in print("status is \(newStatus)") if newStatus == PHAuthorizationStatus.authorized { / do stuff here */ print("success") }

    })

    case .restricted: / print("User do not have access to photo album.")

    case .denied: / print("User has denied the permission.")

  }

}

正確的方法調用 didFinishPickingMediaWithInfo

錯誤:


private func imagePickerController( picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {


@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

希望此解決方案可以幫助您解決此錯誤。


如果對您有用,請別忘了將其標記為正確,這將有助于其他人找到正確的方法。


查看完整回答
反對 回復 2019-12-13
?
白板的微信

TA貢獻1883條經驗 獲得超3個贊

我找到了!它試圖告訴您您沒有“照片”的#import <Photos/Photos.h>授權。例如,需要在Objective-C中包括和請求這樣的授權。


希望這可以節省您一些時間。我花了整整兩天的時間進行調試!


[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {

    switch (status) {

        case PHAuthorizationStatusAuthorized:

            NSLog(@"PHAuthorizationStatusAuthorized");

            break;

        case PHAuthorizationStatusDenied:

            NSLog(@"PHAuthorizationStatusDenied");

            break;

        case PHAuthorizationStatusNotDetermined:

            NSLog(@"PHAuthorizationStatusNotDetermined");

            break;

        case PHAuthorizationStatusRestricted:

            NSLog(@"PHAuthorizationStatusRestricted");

            break;

    }

}];

我相信有人可以告訴您如何在Swift中執行相同的操作。


查看完整回答
反對 回復 2019-12-13
  • 3 回答
  • 0 關注
  • 932 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號