如何关闭 UISearchBar 中的实时搜索
我已经使用 UIViewController、UISearchBarDelegate、UISearchDisplayDelegate 实现了 SearchBar,当执行搜索时,我的程序向服务器发送 http 请求,然后解析响应正文。这将导致搜索栏在每个字符输入后延迟几秒钟。
所以我想关闭搜索栏的“实时搜索”,这样它就不会在我每次输入字符时都执行搜索。当我单击键盘的“搜索”按钮时,我还想执行搜索并将数据显示到表格视图中。我能做些什么?
I have implemented a SearchBar using an UIViewController, UISearchBarDelegate, UISearchDisplayDelegate, and when the search performs, my program send a http request to the server and then parser the response body. And this will cause the search bar delay for a few second after each character typed.
So I want to turn off the "live search" of the search bar so that it will not perform search every time I type a character. And also I want to perform search and display the data to the tableview when I click the "Search" button of the keyboard. What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用 [self.searchDisplayController.searchResultsTableView reloadData];
仅当您的搜索请求已完成时,并且仅在调用委托
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
时才发出搜索请求。call
[self.searchDisplayController.searchResultsTableView reloadData];
only when your search request has been completed and make the search request only when the delegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
is called.