自定义searchResultsTableView

nmo*_*ock 1 ios

我希望有UITableViewCells我的定制UISearchDisplayController.这searchResultsTableView是一个只读属性.我有searchviewcontroller的委托和数据源返回自定义单元格,但是,它似乎仍在使用searchResultsTableView单元格.使用我自己的搜索结果的最佳方法是UITableViewCells什么?

Joh*_*hen 10

搜索开始时,会创建一个全新的UITableView.此新表视图将使用默认设置,与您的表视图不匹配.在你的UISearchDisplayDelegate中,覆盖searchDisplayControllerWillBeginSearch:以重新设置新UITableView的主题,如下所示:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
    // Re-style the search controller's table view
    UITableView *tableView = controller.searchResultsTableView;
    tableView.backgroundColor = [UIColor blueColor];
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
Run Code Online (Sandbox Code Playgroud)