I have added a simple search bar in the header of a TableViewController and implemented the delegate. Everything is working.
What is awfully weird is that the cancel is only called after the second tap.
EDIT: https://www.youtube.com/watch?v=ehnA2kmGqcQ&feature=youtu.be
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
searchBar = UISearchBar(frame: CGRectMake(0, 0, tableView.frame.size.width, 0))
searchBar.barTintColor = kbackgroundColor
searchBar.showsCancelButton = true
searchBar.showsSearchResultsButton = false
searchBar.tintColor = UIColor.whiteColor()
searchBar.delegate = self
return searchBar
}
return nil
}
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
searchInProgress = false
loadObjects()
searchBar.resignFirstResponder()
}