How to implement UISearchController in UITableView - Swift

后端 未结 3 1141
予麋鹿
予麋鹿 2020-12-02 08:20

I am a newbie to Swift and I am trying to add search functionality to my UITableView which is in a UIViewController class. I googled a lot and foun

3条回答
  •  遥遥无期
    2020-12-02 08:51

    For those looking for a bit more context on all the aspects of implementing this, here's a tutorial on how to implement UISearchController

    In addition to the above answer by Andy Ibanez, you also need to add code to your UITableViewDataSource methods to show the newly filtered results in the tableview.

    Also, don't forget to call tableView.reloadData() in your updateSearchResults method - the UISearchController does not automatically tell the tableView to reload its data.

提交回复
热议问题