10
votes

I have a UISearchController, whose searchBar is set as my tableView's tableHeaderView:

tableView.tableHeaderView = searchController.searchBar

It's working great on my device that runs iOS9: enter image description here

But when I run it on my device that's running iOS8 there is no search bar. enter image description here

From what I've read, the UISearchController is available for iOS8 and later. So I do not understand why its searchBar does not show up on my iOS8 device.

1
@MuhammadAdnan I have that already set to truevikzilla

1 Answers

23
votes

UISearchBar is not automatically setting its size add this code:

[searchController.searchBar sizeToFit];

Apple Sample