有没有一种简单的方法来检测 UISearchBar 是否退出“搜索模式”?
我正在尝试设置一个 UISearchBarDelegate
我的第一次尝试是在调用 searchBarShouldEndEditing: 时清除搜索结果,但我发现在滚动搜索结果时会调用它,这不是摆脱数组的时候其中。
我的下一个尝试是 searchBarCancelButtonClicked: - 但如果搜索栏为空并且他们点击下面的空间(显示表格视图的灰色视图),则不会调用此方法。
那么,您如何知道何时从返回搜索结果单元格切换到返回常规表格视图单元格?
感谢您对此的任何帮助。
I'm trying to set up a UISearchBarDelegate
My first attempt was to clear the search results when searchBarShouldEndEditing: was called, but I discovered that this gets called when scrolling through the search results, which is not a time to be getting rid of the array of them.
My next attempt is searchBarCancelButtonClicked: - but this doesn't get called if the search bar is empty and they tap the space below (where a greyed out view of the table view is showing).
So how do you know when to switch from returning search results cells to returning regular table view cells?
Thanks for any help with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以检查哪个表视图正在请求单元格。 searchDisplayController.resultsTableView 是请求您的搜索结果单元格的内容。只需在 cellForRowAtIndexPath 中检查这一点
You can check which table view is requesting the cells. searchDisplayController.resultsTableView is what requests your search results cells. Just check for this in cellForRowAtIndexPath