I am using UISearchDisplayController in my application. When the user selects an item in the search results, I deactivate the UISearchDisplayController. Deactivating the controller clears the text that the user typed. I want to keep it there. I am trying to assign text back to the UISearchBar by setting it again after the controller has been deactivated. The text appears in the search bar, but this will lead to the active action of the UISearchDisplayController, even though I disabled the delegate! This issue only occurs on iOS 7. Before iOS7, the code below works charmingly.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSUInteger row = [indexPath row]; NSString *term = [keywordSuggestion objectAtIndex:row]; [search resignFirstResponder]; [self handleSearchForTerm:term]; } -(void)handleSearchForTerm:(NSString *)searchTerm { [searchDisplayController setActive:NO animated:YES];
Is there a way I can set the text of a UISearchBar without associating it with activating the UISearchDisplayController?
source share