Swift Tap Gesture Recognizer doesn't work : <p>override func viewDidLoad() {</p>

<pre><code>    super.viewDidLoad()


       imageView.isUserInteractionEnabled = true

     let gestureRecognizer = UIGestureRecognizer(target: self, action: #selector(chooseImage))

       imageView.addGestureRecognizer(gestureRecognizer)

    }

     @objc func chooseImage() {

       let pickerController = UIImagePickerController()
        pickerController.delegate = self
        pickerController.sourceType = .photoLibrary
        present(pickerController,animated: true,completion: nil)
    }


    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

        imageView.image = info[.originalImage] as? UIImage
        self.dismiss(animated: true, completion: nil)
    }
</code></pre>

<p>Tap gesture recognizer doesn't work on simulator.I created a photo called select an image but I can't click on it to go through my photo library</p>
