title: Double tap necessary to select TableView item with Search Bar
body: <p>I have a UITableView with a search bar as header.
  I use this function to update my data when the user does a search in the search bar.</p>
  
  <pre><code>func updateSearchResults(for searchController: UISearchController) {
  
      if let searchText = searchController.searchBar.text {
          if (searchText.characters.count &gt; 0) {
              self.filteredResults  = [];
              self.locationManager?.geocodeAddressString(addressString: searchText, completionHandler: { (results, error) in
                  if error == nil &amp;&amp; results != nil {
                      self.filteredResults = results!;
                      self.tableView.reloadData();
                  }
              });
          }
          else {
              self.filteredResults  = [];
              self.tableView.reloadData();
          }
      }
  }
  </code></pre>
  
  <p>and this function when I select a cell in my UITableView.</p>
  
  <pre><code>func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  
      self.delegate?.setCity(city: str);
      self.dismiss(animated: true, completion: nil);
  }
  </code></pre>
  
  <p>Here is my problem : the view controller doesn't dismiss at the first taps on the cell. I taps once, the search bar resign responder. And I need to tap twice for the dismiss to execute.</p>
  
  <p>Here is how I link my tableview and my search bar in viewDidLoad:</p>
  
  <pre><code>// Search Bar componants
  self.searchController = UISearchController(searchResultsController: nil);
  self.searchController.delegate = self;
  self.searchController.searchResultsUpdater = self;
  self.searchController.hidesNavigationBarDuringPresentation = false
  self.searchController.dimsBackgroundDuringPresentation = false;
  
  self.searchBar = self.searchController.searchBar;
  self.searchBar.searchBarStyle = .default;
  self.searchBar.delegate = self;
  self.searchBar.placeholder = NSLocalizedString("search.city", comment: "search.city").capitalized;
  
  self.tableView = UITableView(frame: CGRect.zero, style: .plain);
  self.tableView.translatesAutoresizingMaskIntoConstraints = false;
  self.tableView.delegate = self;
  self.tableView.backgroundColor = UIColor.white;
  self.tableView.dataSource = self;
  self.tableView.tableHeaderView = self.searchBar;
  self.view.addSubview(self.tableView);
  </code></pre>
  
  <p>If someone could help me, that would be great :)</p>