ios - UISearchControllerDelegate - Search bar not visible in table header -
my uitableviewcontroller
conforming new uisearchcontrollerdelegate
, uisearchresultsupdating
.
here setup code search bar:
override func viewdidload() { var searchcontroller = uisearchcontroller(searchresultscontroller: self) searchcontroller.searchresultsupdater = self self.tableview.tableheaderview = searchcontroller.searchbar self.definespresentationcontext = true }
however, when running in simulator there no search bar in table header, though specified in code. tried code in viewwillappear
, again no search bar shown.
i informed apple engineer must give search bar frame. if print frame of search bar, notice it's height zero. bug in apple's code.
searchcontroller.searchbar = cgrectmake(0.0, 0.0, 320.0, 44.0)
edit:
the documentation specifies must pass in view controller want display results. display in same view controller in, pass in nil.
var searchcontroller = uisearchcontroller(searchresultscontroller: nil)
Comments
Post a Comment