iphone:在组部分表格视图中如何禁用搜索结果中的部分?
我正在使用 searchDisplayController,它将搜索名称和部分。我想知道如何仅显示名称而不包括该部分的结果。假设代码与苹果文档中的代码类似。当我查看 tableview 本身时,其中至少有 2000 个名字。
I am using searchDisplayController and it would be searching for the names and also the sections. i would like to know how to show the results of only names and not including the section. Assume the codes are the similar as from apples doc. I have at least 2000 names in there when viewing the tableview itself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想多了解一下你的问题,因为它不太清楚。我实际上不明白这一行:
搜索部分的结果,最好在字典/数组中搜索并通过
[tableView reloadData]
在tableview中显示结果。I would like to a bit more of your problem as it is not much clear. I don't actually get this line:
For searching, it is best to search in a dictionary/array and show the result in tableview by
[tableView reloadData]
.请参阅我对此问题的回答:
UISearchBar 搜索表包含文本、副文本和图像的行
结果表中显示的内容完全取决于您。它甚至不需要与您正在搜索的表有任何关系! (当然通常是这样,否则你会让用户感到困惑。)你只需形成填充结果表的数据即可;那是什么数据,由你决定。
因此,如果您不想包含任何部分标题,那么当查询数据源/委托的表是结果表时,请勿包含任何部分标题!这是你的代码,这是你的桌子,做你想做的事。您是实现
tableView:titleForHeaderInSection:
来返回标题的人;如果您不需要标题,请返回 nil。当然,如果真实表的数据源与结果表的数据源是同一对象,则tableView:titleForHeaderInSection:
必须检查传入的tableView
参数来查看它是真实表还是结果表,并根据该结果选择返回什么。See my answer to this question:
UISearchBar Search table row with text, subtext and image
What you show in a results table is completely up to you. It needn't even have anything to do with the table you're searching! (But of course it usually does, as otherwise you'd confuse the user.) You simply form the data that populates the results table; what data that is, is your call.
So, if you don't want to include any section titles, then when the table inquiring of your data source / delegate is the results table, don't include any section titles! It's your code, it's your table, do whatever you want. You are the one implementing
tableView:titleForHeaderInSection:
to return titles; if you don't want titles, return nil instead. Of course, if the data source for the real table is the same object as the data source for the results table, thentableView:titleForHeaderInSection:
will have to examine the incomingtableView
parameter to see whether it is the real table or the results table, and make its choice of what to return based on that.