如何知道哪个搜索栏处于活动状态?
现在我在一页上有 2 个搜索栏,
第一个问题是如何使搜索按钮始终显示,尽管 searchbar.text 上没有文本?
第二个问题是,我有一个表视图,它将显示不同的列表,消耗我选择的搜索栏,我怎样才能做得好?
我可以设置一个变量,该变量每次搜索栏处于活动状态时都会发生变化。但是,有没有办法查看哪个搜索栏当前是活动搜索栏?
now I have 2 search bar at one page
the first problem is How can I make a search button always show although no text at searchbar.text?
the second problem is, I have a Table View that Will show a different list expend which search bar I choose, how can I do it well?
I can set a variable that change everytime the search bar is active. However is there a way to see which search bar is currently the active search bar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您正在使用哪个视图的最简单方法是分配
tag
属性:您可以轻松检查它:
现在是第二部分。如果你想显示取消按钮,你可以这样做:
如果你想显示范围栏:
如果你想显示搜索结果按钮:
编辑: 如果你想显示
搜索
键盘按钮即使没有输入任何文本,您也可以这样做:我建议您阅读UISearchBar 的文档。
The simplest way to check which view are you working with, is assigning the
tag
property:You can easily check it:
Now, the second part. If you want to show cancel button, you can do it in this way:
If you want to show scope bar:
If you want to show search results button:
EDIT: If you wish to show
Search
keyboard button even if there's no text entered, you can do it in this way:I recommend you reading UISearchBar's documentation.