ios - Error "Application tried to present modal view controller on itself" while activating UISearchController on action -
in code how setup uisearchcontroller:
searchresultcontroller = storyboard!.instantiateviewcontrollerwithidentifier(dbsearchresultcontrolleridentifier) as! dbsearchresultcontroller searchcontroller = uisearchcontroller(searchresultscontroller: searchresultcontroller) searchcontroller.searchresultsupdater = self searchcontroller.delegate = self searchresultcontroller.tableview.tableheaderview = searchcontroller.searchbar on action is:
@ibaction func citybuttontapped(sender: uibutton) { searchcontroller.active = true } but have error:
application tried present modal view controller on itself. presenting controller
uisearchcontroller: 0x7f9a0c04a6a0
the apple documentation uisearchcontroller says following things:
- setting
activeproperty yes performs default presentation of search controller. - set
searchresultscontrollerparameternildisplay search results in same view searching.
so looks using current view controller searchresultscontroller , hence when try set active yes, tries modally present current view on , hence error.
Comments
Post a Comment