UISearchDisplayController 有 ViewController 个问题

UISearchDisplayController with ViewController issues

我有一个 ViewController,它前面有一个导航控制器,里面有一个 TableView 和其他元素。 tableView 也有一个搜索栏,在场景中,除了主 ViewController 我还有一个搜索显示控制器。

功能正常,但我遇到以下 UI 问题:

  1. 虽然我的主视图有黑色背景色(并且大部分元素有黑色背景色),当我向下拖动 tableView 时,会出现一些白色 space.

我还有以下 UI

的初始设置
-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    self.view.backgroundColor = [UIColor blackColor];
    self.tableView.backgroundColor = [UIColor blackColor];

    self.searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.searchDisplayController.searchResultsTableView.separatorColor = [UIColor blackColor];
    self.searchDisplayController.searchResultsTableView.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12);


    [self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor blackColor]];
    [self.searchDisplayController.searchContentsController.view setBackgroundColor:[UIColor blackColor]];
    self.searchDisplayController.searchBar.barStyle = UIBarStyleBlack;
    self.searchDisplayController.displaysSearchBarInNavigationBar = NO;
}
  1. 当我搜索结果时,将 table 向上拖动到搜索栏后,有一个小地方可以看到 table 视图。

有什么办法可以解决这个问题:(?

编辑更新: 两者都解决了从 TableView 中删除搜索栏的问题。在此之后出现另一个问题,即搜索显示控制器的动画没有更新搜索栏。这是通过以下 post 解决的: UISearchBar animation issue

  1. 您必须将 UIView 背景颜色设置为黑色(不仅仅是 UITableView 颜色)。
  2. 您必须将 table 视图定位在 UISearchBar 下方,您可以通过编程或通过 IB 执行此操作。我推荐第二种选择。很简单。