how could i disable auto search for Three20 search bar
Domanda
I am using Three20 framework, and the auto search feature make the searching really slow, i'd like to disable the auto search and fire the searching once the user clicks on the "Search" button on the pad.
Is there any way i can disable the auto search? Thanks a lot
Soluzione
Create a new display controller XXSearchDisplayController
derived from TTSearchDisplayController
, in the XXSearchDisplayController.m
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString {
return NO;
}
This will disable the auto searching. After this, go to your class derived from TTTableViewController
, say XXProductsTableViewController
@implementation XXProductsTableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
UISearchBar* searchBar = [[UISearchBar alloc] init];
searchBar.delegate = self;
_searchController = [[XXSearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
}
return self;
}
#pragama mark - UISearchBarDelegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[self.searchViewController.dataSource search:searchBar.text];
}
@end
The above code will do the searching once the user clicks on the "Search" button
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow