更新时间:2023-12-01 23:28:46
制作 UISearchController $ c $的搜索结果c>出现在您选择的新
UITableView
中,执行以下操作:
To make the search results of a UISearchController
appear in a new UITableView
of your choice, do this:
let searchController = UISearchController(searchResultsController: myTableViewController)
而不是:
let searchController = UISearchController(searchResultsController: nil)
将视图控制器传递给构造函数允许 UISearchController
在适当的时间显示视图控制器(即搜索处于活动状态时)。这就是你需要做的。
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.
传递 nil
意味着,我正在使用我自己的观点控制器(和表视图)。