swift3 - Make Search Bar Become First Responder -


i have uisearchcontroller inside of uinavigationbar. user has tap on uibarbuttonitem, in instantiate new uiviewcontroller present it, in order begin searching.

class viewcontroller: uiviewcontroller {    var searchcontroller: uisearchcontroller!     override func viewdidload() {     super.viewdidload()     setupsearchcontroller()   }    func setupsearchcontroller() {     searchcontroller = uisearchcontroller(searchresultscontroller: nil)     searchcontroller.searchbar.delegate = self     searchcontroller.searchresultsupdater = self     searchcontroller.searchbar.showscancelbutton = true     searchcontroller.dimsbackgroundduringpresentation = false     searchcontroller.hidesnavigationbarduringpresentation = false      definespresentationcontext = true     navigationitem.titleview = searchcontroller.searchbar   } } 

i've done plenty of research before hand, still can't manage find solution...

help in making search controller become first responder appreciated.

do this,

extension searchmovieviewcontroller: uisearchcontrollerdelegate {    func didpresentsearchcontroller(_ searchcontroller: uisearchcontroller) {     searchcontroller.searchbar.becomefirstresponder()   } } 

you want searchbar firstresponder not searchcontroller , should work.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -