在我的应用程序中,我使用UISearchController(iOS 8中的新增功能)来显示搜索结果。 有没有办法显示一个默认的结果集,当用户点击searchBar而不输入任何内容时会出现这些结果? 我找到了一些关于这个主题的问题和答案,但他们都使用了旧的UISearchDisplayController,我似乎无法使用UISearchController解决方案。
由于
答案 0 :(得分:0)
self.searchController.searchBar.text = @"\n";
似乎要做的伎俩。哈基 - 但是,嘿,好像我们没有其他很多东西可以合作。
答案 1 :(得分:0)
我认为这种方法更好,当searchBar为空时要小心,然后preload tableview会再次消失。
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
if searchText.isEmpty {
dispatch_async(dispatch_get_main_queue()) {
self.searchController.searchResultsController?.view.hidden = false
}
}
}
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
dispatch_async(dispatch_get_main_queue()) {
self.searchController.searchResultsController?.view.hidden = false
}
}
func willPresentSearchController(searchController: UISearchController) {
dispatch_async(dispatch_get_main_queue()) {
self.searchController.searchResultsController?.view.hidden = false
}
}