Here I used the UIsearchBar in "TO" and when user search something, I used the UITableView to show the search results. When user select a row from that results table, it will go to the detail page. But In this situation, when user tap on the UITable View, It does not trigger the UITableView Delegate, didSelectRowAtIndexPath. Instead, dismiss the keyboard . Then user need to tap again on the table after dismissing the keyboard. Therefore, user needs to tap twice whenever he wants to select a row from the result table. Could anyone help me for that problem?
#pragma mark - UISearchBarDelegate
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
if ([self.delegate respondsToSelector:@selector(showCalloutRouteDestinationView:)])
[self.delegate showCalloutRouteDestinationView:(int)searchBar.tag];
return YES;
}
- (BOOL)textFieldShouldEndEditing:(UISearchBar *)searchBar
{
return YES;
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if ([self.delegate respondsToSelector:@selector(showSearchFromResult:andTag:)])
[self.delegate showSearchFromResult:searchText andTag:(int)searchBar.tag];
}
Here is my implementation for didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *location = self.searchByTextResults[indexPath.row];
NSString *type = location[SERVER_CATEGORY];
if (indexPath.row == 0 && self.isTxtFrom){
if ([self.delegate respondsToSelector:@selector(selectAmenity:context:)])
[self.delegate selectMyLocation:self.currentLocation];
return;
}else{
if ([self.delegate respondsToSelector:@selector(didSelectDataForRoute:andType:context:)])
[self.delegate didSelectDataForRoute:(self.isTxtFrom ? self.searchByTextResults[indexPath.row - 1]: self.searchByTextResults[indexPath.row]) andType:type context:self.locationContext];
}
}