Skip to main content

Posts

Showing posts with the label uisearchbar

Resetting UISearchbar programmatically

Is there a possibility to reset a UISearchbar with searchDisplayController programmatically which is active and already contains text? - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView == self.searchDisplayController.searchResultsTableView) { searchDisplayController.searchResultsTableView.hidden = YES; searchBar.showsCancelButton = NO; [searchBar resignFirstResponder]; } } This solution is working, but there is still text in the searchBar. If i add those lines of code: searchBar.text = @""; There is always a black transparent view left. Any solutions?

Subclassing UISearchDisplayController For Abstraction

I have multiple UIViewController that have table views. I want these VCs to just handle UI stuff as they will all search the same database. I want to subclass UISearchDisplayController so I can have this subclass handle all the data and search stuff. The VC I am working with is a UIViewController with a UITableView and a UISearchDisplayController . I have it set and can check to display the initial, or the searched data into the table view by using if/else statements like: if (tableView == self.searchDisplayController.searchResultsTableView) % else... I want this custom subclass that I'm creating to handle the code that is executed in the self.searchDisplayController.searchResultsTableView statement so I can have some abstraction and can use this custom class with other VCs. Any ideas on how to continue with this? I think I need to override some methods in the UISearchDisplayController . EDIT: Actually I may be coming into this wrong. I have it stepup the way I l