2021年3月23日星期二

swift my UIImagePicker doesn't show any image on select image from photo library

everyone I take an imageView and set an image on it, I want to select an image from the photo library if the user tapped on the image here my code is

    @IBOutlet weak var uploadImage: UIImageView!      var imagePicker = UIImagePickerController()  override func viewDidLoad() {          super.viewDidLoad()                    let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))          uploadImage.isUserInteractionEnabled = true          uploadImage.addGestureRecognizer(tapGestureRecognizer)      }      @objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)      {          print("image tapped")          if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary){              print("Button capture")              let imag = UIImagePickerController()              imag.delegate = self as? UIImagePickerControllerDelegate & UINavigationControllerDelegate              imag.sourceType = UIImagePickerControllerSourceType.photoLibrary;              imag.allowsEditing = false              self.present(imag, animated: true, completion: nil)          }      }            func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {          let selectedImage : UIImage = image          uploadImage.image=selectedImage          self.dismiss(animated: true, completion: nil)      }  

but it doesn't show image after select an image from the photo library,
it shows me the message in debug area - [1098:24494] [discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

https://stackoverflow.com/questions/66775063/swift-my-uiimagepicker-doesnt-show-any-image-on-select-image-from-photo-library March 24, 2021 at 01:06PM

没有评论:

发表评论