title: searchBarCancelButtonClicked function isn't being called
body: <p><strong>Problem</strong></p>
  
  <p>If I press the <em>Cancel</em> button when the searchbar is active (i.e. the blinking typing-indicator and keyboard are showing) the <em>searchBarCancelButtonClicked</em> function is run and "Cancel Pressed" is printed. </p>
  
  <p>However, if the <em>Cancel</em> button is pressed when the searchBar is not active (i.e. no typing indicator, and no keyboard showing) the <em>searchBarCancelButtonClicked</em> function IS NOT called. Rather, the <em>searchBarTextDidBeginEditing</em> function is called. </p>
  
  <p><strong>Questions</strong></p>
  
  <p>1) Is this normal behaviour?
  2) How would I change this so that the <em>searchBarCancelButtonClicked</em> function is run even when the searchBar is not active (first responder)?</p>
  
  <p><strong>Note</strong></p>
  
  <p>I am not using the UISearchController, only the UISearchBar and UISearchBarDelegate functions.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>func searchBarTextDidBeginEditing(_ searchBar: UISearchBar)
  {
      DispatchQueue.main.async
      {
          self.searchBarHeader.setShowsCancelButton(true, animated: true)
      }
  
      searchActive = true
      tableView.reloadData()
  }
  
  func searchBarCancelButtonClicked(_ searchBar: UISearchBar)
  {
      print("Cancel Pressed")
      DispatchQueue.main.async
      {
          self.searchBarHeader.setShowsCancelButton(false, animated: true)
          searchBar.resignFirstResponder()
      }
  
      searchBarHeader.text = ""
      searchActive = false
      filteredStopArray = []
      tableView.reloadData()
  }
  
  func searchBarSearchButtonClicked(_ searchBar: UISearchBar)
  {
      DispatchQueue.main.async
      {
          searchBar.resignFirstResponder()
      }
  }
  
  func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
  {
      filteredStopArray = stopArray.filter(
      { (dict) -&gt; Bool in
  
          let nameString: NSString = dict["Name"]! as NSString
          let range = nameString.range(of: searchText, options: NSString.CompareOptions.caseInsensitive)
          return range.location != NSNotFound
      })
  
      tableView.reloadData()
  }
  </code></pre>