I’ve got a UISearchBar and a seperat UITableView. When the user types something in the SearchBar I call my API and then reload the TableView to display the new results. Everytime the TableView reloads the SearchBar loses focus. How can I prevent this?
I tried [_searchBar becomeFirstResponder]; but it didn’t help. Any other ideas?
Thanks for your help.
(Edit) Code I used to reload the data:
[self.fetchedResultsController updateWithObjectList:_newList removeMissing:YES];
- (void)updateWithObjectList:(NSArray *)objectList removeMissing:(BOOL)removeMissing {
if (removeMissing) {
[self removeObjectList:[_objects allValues]];
}
[self addObjectList:objectList];
}
It looks like you are dealing with a hand built (non
CoreData) array for theTablevViewdatasource. If that is the case, why are you using afetchedResultsController?Why not rebuild the array (datasource) for the TableView and then just call
(substitute whatever you have called your
TableViewfor myTableView). If you need a complete example of how to do this, let me know.