title: Dismiss keyboard for textfield in uitableviewcell in tableviewcontroller - Swift
body: <p>I have a textfield and textview in my custom tableviewcell. </p>
  
  <p>I have 4 different prototype cell with 4 different class created. there is a textfield in 1 prototype cell and a textview in the other.</p>
  
  <p>I am not sure how I can do it and I dont understand the obj-c answers out there. </p>
  
  <p>I've tried </p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      let tap: UIGestureRecognizer = UIGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKeyboard))
      view.addGestureRecognizer(tap) }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>func dismissKeyboard() {
      self.view.endEditing(true)
  }
  </code></pre>
  
  <p>I wanted to try</p>
  
  <p><code>UITextFieldDelegate</code> and <code>touchesbegan</code> and <code>textfieldshouldreturn</code> method, but there are no textfields to call in my tableviewcontroller.</p>