开发者

iphone hide UISearchDisplayController results?

I currently have a UISearchBar and UISearchDisplayController implemented as:

- (void) viewDidLoad {

 videoList = [[NSMutableArray alloc]init];

 //Add the search bar
 aSearchBar = [[开发者_Python百科UISearchBar alloc] initWithFrame:CGRectZero];
    [aSearchBar sizeToFit];
 aSearchBar.delegate = self;
    aSearchBar.placeholder = @"Search YouTube...";

    self.tableView.tableHeaderView = aSearchBar;

    searchDC = [[UISearchDisplayController alloc] initWithSearchBar:aSearchBar contentsController:self];

    [self performSelector:@selector(setSearchDisplayController:) withObject:searchDC];

    searchDC.delegate = self;
    searchDC.searchResultsDataSource = self.tableView.dataSource;
    searchDC.searchResultsDelegate = self.tableView.delegate;

    [aSearchBar release];
    [searchDC release];

}

When the user types something and hits search, a tableView appears on top of the tableView in the background.

Is there anyway of hiding this 'searchResults tableView' ? (I just want the background table to hold the data..which it currently does).

i.e. is there a property? e.g. searchDisplayController.tableView.visible=NO or similar?


This however doesn't dismiss the search interface (search bar and "cancel" button). The next code does it:

    [self.searchDisplayController setActive:NO animated:YES];


searchDC.searchResultsTableView.hidden=YES;


[[UISearchBar alloc] initWithFrame:CGRectZero];

don't use CGRectZero self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.table.frame.size.width, 44)];

try it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜