【问题标题】:"Swift Core Data" How to add a Scope Bars to UISearchBar? [closed]“Swift Core Data”如何向 UISearchBar 添加 Scope Bars? [关闭]
【发布时间】:2023-03-31 09:13:01
【问题描述】:
所以,我有一个tableView 和NSFetchedResultsController!我还有一个UISearchController,而且效果很好!但我需要UISearchBar 的范围栏。如何在 Swift Core Data 中创建和添加 Scope Bars?
谢谢!
【问题讨论】:
标签:
swift
core-data
uisearchbar
nsfetchedresultscontroller
uisearchcontroller
【解决方案1】:
只需在您从 UISearchController 获取搜索栏时提供scopeButtonTitles。当您展示搜索控制器时,将搜索结果控制器设置为搜索栏的委托,因此当用户更改范围按钮时它将获得searchBar:selectedScopeButtonIndexDidChange:,您只需调用updateSearchResultsForSearchController 并处理您已经完成的搜索正在做 - 现在考虑当前范围按钮索引是什么。