在 UITableview 上方添加搜索栏
如何在 UITableView 上方添加搜索栏?仅搜索栏就足够了,还是选择搜索栏和搜索显示?
我想用搜索找到的项目重新绘制表格视图。
How is a searchbar added above a UITableView? Would just the searchbar be enough or would the search bar and search display be chosen?
I want to redraw the tableview with the items that are found by the search.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UISearchDisplayController
是专门为解决您的问题而设计的。您应该能够通过阅读文档了解如何使用它。当然,您可以自己处理
UISearchBar
(如果您想构建自己的搜索栏,甚至可以处理UITextField
)。下面是一些可以帮助您入门的代码:
几乎剩下要做的就是实现委托。如果您需要任何帮助,请告诉我,但我可以建议您针对一路上遇到的每个问题提出一个新问题。当然,如果您在这里发表评论,我会看一下。
UISearchDisplayController
is specifically designed to solve your problem. You should be able to figure out how to use it from reading the documentation.Of course you could just handle the
UISearchBar
(or evenUITextField
if you want to build your own search bar) yourself.Here's some code to get you started:
Pretty much all there's left to do is to implement the delegates. If you need any help with that let me know, but may I suggest you ask a new question for each problem you encounter a long the way. Of course if you leave a comment here I will take a look at it.