I have a search bar with cancel button. But when I click on Cancel button it doesn\'t close the search bar. How can I make that on click on Cancel it will return search bar to t
For Objective-C solution
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
if(@available(iOS 11.0, *)){
[self.navigationController.navigationItem.searchController.searchBar resignFirstResponder];
}
// reload your table or whatever you want.
// searchController is available after the iOS 11, so it will be good to use @available check
}