最近,我注意到filterContentForSearchText:scope:
出现在有关如何实现搜索栏的多个教程中。
不过,我查阅了两者的参考资料UISearchDisplayDelegate and UISearchBarDelegate
。我找到了这个filterContentForSearchText:scope:
既不是必需的也不是可选的方法。
我想知道是否filterContentForSearchText:scope:
只是一个过滤搜索结果的常规方法名称?
是的,这只是从UISearchDisplayDelegate
methods
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString;
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption;
目前的“具有状态恢复的简单 UISearchBar” https://developer.apple.com/library/ios/samplecode/TableSearch/Introduction/Intro.htmlApple 的示例项目确实not使用这个约定:
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
NSString *scope;
NSInteger selectedScopeButtonIndex = [self.searchDisplayController.searchBar selectedScopeButtonIndex];
if (selectedScopeButtonIndex > 0)
{
scope = [[APLProduct deviceTypeNames] objectAtIndex:(selectedScopeButtonIndex - 1)];
}
[self updateFilteredContentForProductName:searchString type:scope];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)