title: Hide keyboard when a textField is clicked
body: <p>I want to hide the keyboard every time a user click on the textField named <code>typeDeProbleme</code>. So, I did something like below (in the if condition) which in my understanding should've work but unfortunately it's not. Every time I click on the <code>typeDeProbleme</code>, the keyboard is stuck and cannot be hidden unless I click on another textField. For your information, <code>typeDeProbleme</code> is a textField linked to a PickerView. I also attached a toolbar on top of my keyboard that have a button X to hide the keyboard. Can anyone explain to me where is the problem?  </p>
  
  <p><a href="https://i.stack.imgur.com/klnt4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/klnt4.png" alt="enter image description here"></a></p>
  
  <pre><code>func textFieldDidBeginEditing(_ textField: UITextField) {
      textField.returnKeyType = .next
  
      if textField == self.typeDeProbleme {
          textField.endEditing(true)// hide keyboard
          textField.resignFirstResponder() //hide keyboard
          self.pbTypePickerV.isHidden = false
      }else{
          keyboardDidShow(vvv: textField)
      }
  }
  </code></pre>