Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchController not showing on iOS8

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.

like image 614
vikzilla Avatar asked Apr 08 '16 04:04

vikzilla


1 Answers

UISearchBar is not automatically setting its size add this code:

[searchController.searchBar sizeToFit];

Apple Sample

like image 67
A Trâu Avatar answered Oct 04 '22 13:10

A Trâu