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 active property yes performs default presentation of search controller.
  • set searchresultscontroller parameter nil display 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

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -