没有即时搜索的 UISearchDisplayController:如何控制 TableView 的变暗?
我已经使用 Apple 的 TableSearch 示例参考实现了 UISearchDisplayController 。我的列表包含超过 10,000 个元素,这使得过滤速度太慢,无法对用户输入的每个字符执行过滤。我已设法将搜索限制为当用户使用以下代码单击搜索按钮时。
- (void)searchBarSearchButtonClicked:(UISearchBar*)searchBar
{
[self filterContentForSearchText:[self.searchDisplayController.searchBar text]
scope:[self.searchDisplayController.searchBar selectedScopeButtonIndex]];
[self.searchDisplayController.searchResultsTableView reloadData];
}
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller
shouldReloadTableForSearchString:(NSString*)searchString
{
return NO;
}
现在,我的问题是,一旦用户输入第一个字符,表格视图的变暗就会消失,我想保持它变暗,直到用户单击“搜索”按钮。 (或取消搜索。)
I have implemented a UISearchDisplayController using Apple's TableSearch sample reference. My list contains just over 10.000 elements, and this makes the filtering too slow to execute it on every character that the user enters. I've managed to restrict to search to when the user click on the search button with the following code.
- (void)searchBarSearchButtonClicked:(UISearchBar*)searchBar
{
[self filterContentForSearchText:[self.searchDisplayController.searchBar text]
scope:[self.searchDisplayController.searchBar selectedScopeButtonIndex]];
[self.searchDisplayController.searchResultsTableView reloadData];
}
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller
shouldReloadTableForSearchString:(NSString*)searchString
{
return NO;
}
Now, my problem is, that as soon as the user enters the first character the dimming of the table view disappears, and I would like to keep it dimmed until the user clicks the Search buton. (Or cancels the search.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
searchDisplayController 是一个黑盒子,因此您无法控制它何时显示 searchResultsTableView(在搜索栏中按下第一个按键时显示)。
您可以在 resultsTableView 上显示半透明视图,以提供由 searchDisplayController 提供的初始变暗的外观,但 searchResultsTableView 仍然可见。
另一种选择是编写您自己的代码。
The searchDisplayController is a black box so you don't have any control over when it displays the searchResultsTableView (which in on first key press in the searchBar).
You could display a translucent view over the resultsTableView to give the appearance of the initial dimming provided by the searchDisplayController but the searchResultsTableView will still be visible.
The other option is to code your own.