如何在激活搜索栏时显示searchResultsTableView?

Ron*_*Ron 6 uisearchdisplaycontroller ios

我正在实现一个UISearchDisplayController,我想searchResultsTableView在加载文本之前填充tableView(未过滤)的内容 - 在输入文本之前.

这在我开始在searchBar中输入值时有效.

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
    self.isSearching = YES;

    //tell the searchDisplayTableView to show here!

    [controller.searchBar setShowsCancelButton:YES animated:YES];
}

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
    self.isSearching = NO;
    [controller.searchBar setShowsCancelButton:NO animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

有人会指出正确的方向吗?

请不要回答"不要那样做"或"Apple没有设计控制方式".要么 ...

Ron*_*Ron 0

苹果的控制就是这样的。我通过实现一个单独的控制器(称为搜索显示控制器)对象来解决这个问题,该对象是搜索栏委托并将谓词应用于数据源。这样,表格视图就被“内联”过滤。