I've a problem. I trying to set the background of an searchResultsTableView. Into my SearchViewController implementation, during the viewDidLoad, I want to set the background either of my self.tableView and of self.searchDisplayController.searchResultsTableView. I do this:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"Search";
UIColor *customColor = [UIColor colorWithRed:255.0 green:252.0 blue:227.0 alpha:1.0];
self.tableView.backgroundColor = customColor;
self.searchDisplayController.searchResultsTableView.backgroundColor = customColor;
}
After this, I've the tableView with my custom light-yellow color but, when I tap the search bar, and the tableView was replaced by searchDisplayController.searchResultsTableView, this results white.
Thanks for any help.
Use this method .. it will call when you start searching..
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"default.png"]];
}
That i-Blue's solution with didLoadSearchResultsTableView works just fine. However I define search result background color this way:
- (void)viewWillAppear:(BOOL)animated
{
self.searchDisplayController.
searchResultsTableView.backgroundColor =
[UIColor blueColor];
[super viewWillAppear:animated];
}
So far no problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With