" Swift核心数据"如何向UISearchBar添加范围栏?

时间:2016-03-11 02:44:48

标签: swift core-data uisearchbar nsfetchedresultscontroller uisearchcontroller

所以,我有tableView NSFetchedResultsController!我还有UISearchController,效果很好!但我需要UISearchBar的范围栏。如何创建以及如何在Swift Core Data中添加Scope Bars?

谢谢!

1 个答案:

答案 0 :(得分:2)

在您从UISearchController获取搜索栏时scopeButtonTitles。当您显示搜索控制器时,将搜索结果控制器设置为搜索栏的委托,因此当用户更改范围按钮时它将获得searchBar:selectedScopeButtonIndexDidChange:,您只需调用updateSearchResultsForSearchController并将搜索作为搜索处理你已经在做了 - 现在考虑当前范围按钮索引是什么。