title: Allow taps to pass through UITapGestureRecognizer and reach table view below
body: <p>I'm implementing a search controller with a search bar on top and a tableview below which displays the results of the search. I added the following code so that when a user taps on the screen, the keyboard will be dismissed. </p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
      self.view.addGestureRecognizer(tapGesture)
  }
  
  @objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
      if let view = self.view {
          view.endEditing(true)
      }
  }
  </code></pre>
  
  <p>However, now when I try to implement the <code>didSelectRowAt</code> method of the table view, it doesn't work as the <code>UITapGestureRecognizer</code> defined in the code above captures the touch event. Ideally, I'd like the tableview touches to take precedence over the code above, so that when a user touches the tableView, <code>didSelectRowAt</code> is called, but when he touches anywhere else on screen, <code>dismissKeyboard</code> is called instead.</p>