2

I've making practises to use iOS 8 new features - UISearchController to display my tableView and result. But something strange happened. It seems like the searchBar is transparent.

Yes, the searchBar is overlapping with the tableView. I've search a lot in SO, but no help.

enter image description here

My implementation in viewDidLoad

self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; _myTableView.delegate = self; _myTableView.dataSource = self; [self.view addSubview:_myTableView]; self.mySearchController = [[UISearchController alloc] initWithSearchResultsController:nil]; _mySearchController.searchResultsUpdater = self; _mySearchController.dimsBackgroundDuringPresentation = NO; _mySearchController.hidesBottomBarWhenPushed = YES; _mySearchController.hidesNavigationBarDuringPresentation = YES; _mySearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal; [_mySearchController.searchBar sizeToFit]; self.myTableView.tableHeaderView = self.mySearchController.searchBar; 

Did I miss something important?

4
  • try to add [_myTableView setContentOffset:CGPointMake(0, 44)] Commented Dec 12, 2014 at 15:19
  • Try to create a UIView with rect (0, 0, tableView.frame.size.width, 44), put there your search bar and than set this view as tableHeaderView Commented Dec 12, 2014 at 15:51
  • @NilsHolgerson try both, not working. Commented Dec 13, 2014 at 2:42
  • @anatoliy_v try, seem likes the search bar is transparent Commented Dec 13, 2014 at 2:44

1 Answer 1

1

It's because you've set _mySearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal. According to Apple's documentation:

UISearchBarStyleMinimal - The search bar has no background, and the search field is translucent.

Try deleting that line of code or setting it to UISearchBarStyleDefault instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.