How to show tableview when user taps searchbar swift

别等时光非礼了梦想. 提交于 2019-12-01 18:43:06

To make the search results of a UISearchController appear in a new UITableView of your choice, do this:

let searchController = UISearchController(searchResultsController: myTableViewController)

instead of this:

let searchController = UISearchController(searchResultsController: nil)

Passing a view controller to the constructor allows the UISearchController to display the view controller at appropriate times (i.e. when the search is active). This is what you need to do.

Passing nil means, I'm using my own view controller (and table view).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!