I have a UISearchBar on my MKMapView that I'm going to use to search annotations. I'm having trouble getting the cancel button to work. I create the search bar in my viewDidLoad method like this:
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchBar.frame = CGRectMake(0, 0, 320,44);
searchBar.showsBookmarkButton = NO;
searchBar.showsCancelButton = YES;
[self.view addSubview:searchBar];
And I've implemented this method for the cancel button:
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
}
What am I doing wrong?