Radu Vlad
Radu Vlad

Reputation: 1514

UISearchDisplayController with ViewController issues

I have a ViewController with a Navigation Controller before it, that has a TableView and other elements inside. The tableView has also a Search Bar, and in the scene, besides the main ViewController I have a Search Display Controller.

The functionality is working, but I have the following UI issues:

  1. Although my main view has black background colour(and most of the elements have black background colour), when I drag the tableView downwards there appears some white space.

enter image description here

I also have the following initial setup for 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. When I search for a result, and drag the table upwards after the Search Bar, there is a small place where the table view is visible.

enter image description here

Any ideas how can I fix this :(?

Edit update: Both were solved removing the Search Bar from the TableView. After this another issue came that the animation of Search Display Controller wasn't updating the Search Bar. this was solved with the following post: UISearchBar animation issue

Upvotes: 2

Views: 82

Answers (1)

Evgeniy Kleban
Evgeniy Kleban

Reputation: 6940

  1. You have to set UIView background color to black (not just UITableView color).
  2. You have to position your table view below UISearchBar, you can do this either programmatically or via IB. I recommend second option. Pretty easy.

Upvotes: 2

Related Questions