ios - How to fix table view's search bar overlapping with status bar -
i have uitableviewcontroller inside navigation controller, search bar. how add search bar in viewdidload:
let resultscontroller = searchtableviewcontroller() resultscontroller.people = people searchcontroller = uisearchcontroller(searchresultscontroller: resultscontroller) let searchbar = searchcontroller.searchbar searchbar.placeholder = "search person" searchbar.sizetofit() tableview.tableheaderview = searchbar searchcontroller.searchresultsupdater = resultscontroller
this result:
i tried editing table view in storyboard add constraint make further top view's margins, can't add contraints, because table view inside uitableviewcontroller.
i think need code.
in viewdidload
method add code:
self.tableview.contentinset = uiedgeinsetsmake(20, 0, 0, 0)
and tableview this:
edit:
you can forcely scroll table code:
tableview.scrolltorowatindexpath( nsindexpath(index: 0), atscrollposition: uitableviewscrollposition.top, animated: false)
Comments
Post a Comment