iPhone - 更改 UISearchDisplayController“取消”按钮文字
排序问题: 有没有办法将 UISearchDisplayController 中的“取消”按钮文本更改为“完成”或“关闭”?
理由:
我有一个包含选项列表的 UITableView,每个选项都可以选中或取消选中。
我想通过这些选项启用搜索,因此我创建并添加了一个 UISearchDisplayController
。
用户将搜索项目,然后对搜索结果中的项目执行操作(即选择/取消选择某些项目)。
一旦完成,用户将返回到之前的(未搜索的)选项列表。
问题是关闭 UISearchDisplayController 的唯一方法是按“取消”按钮。然而,“取消”在这里是错误的词,因为在搜索栏中执行的操作将被存储。
因此,有没有办法将“取消”按钮文本更改为“完成”或“关闭”?
Sort question:
Is there a way to change the "Cancel" button text within a UISearchDisplayController
to "Done" or "Close"?
Rationale:
I have a UITableView
that contains a list of options, each option can be checked or unchecked.
I want to enable search through these options, so I've created and added a UISearchDisplayController
.
The user will search for an item, and then perform actions on the items in the search results (i.e. will select/unselect certain items).
Once this is completed the user will then go back to the previous (unsearched) list of options.
The problem is that the only way to dismiss the UISearchDisplayController
is to press the "Cancel" button. However "Cancel" is the wrong word here as the actions conducted while within the Search bar will be stored.
Therefore, is there a way to change the "Cancel" button text to "Done" or "Close"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一种方法来做到这一点,在搜索栏的委托中,创建一个空动画,然后在一小段时间后,更改按钮上的内容,这可能是因为取消按钮在调用委托后不久就会出现动画,因此你不能抓住它并在此之前更改它:
I found one way to do this, in the delegate for the searchbar, create an empty animation then after a small duration, change your things on the button, this might be because the cancel button is animated in sometime shortly after the delegate is called, thus you cant grab it and change it before that: