Frage

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

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top