iphone:在组部分表格视图中如何禁用搜索结果中的部分?

发布于 2024-12-19 13:17:43 字数 188 浏览 2 评论 0原文

我正在使用 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.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放赐 2024-12-26 13:17:44

我想多了解一下你的问题,因为它不太清楚。我实际上不明白这一行:

我想知道如何仅显示名称而不包含该部分的结果

搜索部分的结果,最好在字典/数组中搜索并通过[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:

i would like to know how to show the results of only names and not including the section

For searching, it is best to search in a dictionary/array and show the result in tableview by [tableView reloadData].

樱&纷飞 2024-12-26 13:17:43

请参阅我对此问题的回答:

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, then tableView:titleForHeaderInSection: will have to examine the incoming tableView parameter to see whether it is the real table or the results table, and make its choice of what to return based on that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文