I think this method is better, be careful when the searchBar is empty and the preload tableview disappears again.
UISearchBarDelegate
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { if searchText.isEmpty { dispatch_async(dispatch_get_main_queue()) { self.searchController.searchResultsController?.view.hidden = false } } } func searchBarTextDidBeginEditing(searchBar: UISearchBar) { dispatch_async(dispatch_get_main_queue()) { self.searchController.searchResultsController?.view.hidden = false } }
UISearchControllerDelegate
func willPresentSearchController(searchController: UISearchController) { dispatch_async(dispatch_get_main_queue()) { self.searchController.searchResultsController?.view.hidden = false } }
source share