2

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

Community
  • 1
  • 1
Radu Vlad
  • 1,474
  • 2
  • 21
  • 37

1 Answers1

2
  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.
Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
  • 1. `self.view.backgroundColor = [UIColor blackColor];` `self.tableView.viewForBaselineLayout.backgroundColor = [UIColor blackColor]; ` this does nothing. 2.What does IB mean? – Radu Vlad Jul 01 '15 at 13:10
  • 1. Use self.view. UITableView is a subview for UIView, nothing more. 2. IB stand for Interface builder (storyboard, xib). You can arrange position of your interface elements neither through IB or programmatically set frames coords. – Evgeniy Kleban Jul 01 '15 at 13:12
  • 1. Already did that, as you can see above. 2. Am trying, will come back. – Radu Vlad Jul 01 '15 at 13:14
  • Please, edit your post with code, you use for setting color for every element. And paste code when you set color for self.view. – Evgeniy Kleban Jul 01 '15 at 13:17
  • 1. Will update my post asap 2. When I click on the search, nav bar animates out and table view becomes bigger. How do I make the Search Bar animate with the table view and the nav bar as well? – Radu Vlad Jul 01 '15 at 13:25
  • 1. my bad, I think by mistake I build an old version or something. Now the problem 1 is solved. – Radu Vlad Jul 01 '15 at 13:30
  • @RaduVlad. im not sure i can answer that question without examine full code, i prefer you to go through tutorials like that: http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view In my own app, i just place search bar on top of UITableView, connect via outlets and implement default methods, default animation was pretty nice and without conflicts. – Evgeniy Kleban Jul 01 '15 at 13:37