选择搜索栏时显示searchDisplayController.searchResultsTableView

时间:2012-09-23 23:22:30

标签: iphone uisearchbar uisearchdisplaycontroller

我想在选择searchBar时显示searchResultsTableView。我试过这个:

- (void) searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
    [self.searchDisplayController.searchResultsTableView reloadData];
    [self.searchDisplayController setActive:YES animated:YES];
}

和此:

- (void) searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
    [self.searchDisplayController setActive:YES animated:YES];
}

两者都不起作用。在我的numberOfRowsInSection方法中,我在数组中有行,但是在我开始输入之前,searchResultsTableView没有显示。有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

尝试在以下UISearchBarDelegate方法中将searchdisplaycontroller设置为活动

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar;