I have a searchbar in my application, but when I run it in simulator, it doesn't allow me to type in the search field.
In my code, the search bar is created in the xib file and then added as a subview of map view (programmatically) so that it lays on top of the map. Some of my code for my search bar:
[mapView addSubview: searchBar];
searchBar.placeholder = @"Search or Place Pin";
searchBar.searchBarStyle = UISearchBarStyleProminent;
searchBar.backgroundImage =[[UIImage alloc]init];
searchBar.barTintColor = [UIColor clearColor];
searchBar.delegate = self;
-(void) viewDidAppear:(BOOL)animated{
...
[searchBar becomeFirstResponder];
BOOL searchBarIsResponding = [searchBar becomeFirstResponder];
NSLog(@"first responder: %d", searchBarIsResponding);
....
- (void) searchBarButtonClicked:(UISearchBar *)searchBar
{
[self searchCoordinatesForAddress:[searchBar text]];
[searchBar resignFirstResponder];
}
Edit: I tried setting mapView's userInteractionEnabled to NO to see whether it was an issue of mapView not passing its touches to searchBar, but I still couldn't type in searchBar, so I don't think that's the problem.