Search code examples
objective-ciosuisearchdisplaycontroller

Hiding table view of search display controller


I want to make search display controller to work in this way:

When user press on search field it goes up to top and keyboard shows up. Normally this is happening but when user types something then shows up table view.

I don't want to do anything while user typing and when he press Search then i do this:

 [_searchController setActive:NO animated:YES];

and load data in my custom create table view.

How could i do this kind of functionality.

EDIT. I found some of solution:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    savedSearchTerm = searchString;

    [controller.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.8]];
    [controller.searchResultsTableView setRowHeight:800];
    [controller.searchResultsTableView setScrollEnabled:NO];
    return NO;
}

Maybe someone have a better way?


Solution

  • You can set the hidden property of searchResultsTableView

    controller.searchResultsTableView.hidden = YES;
    

    Whenever you want it back just set hidden to NO and bring it to the front in case it is already displayed

    controller.searchResultsTableView.hidden = NO;
    [controller.searchResultsTableView.superview bringSubviewToFront:controller.searchResultsTableView];