首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UISearchBarDelegate和textFieldShouldClear替代方案

UISearchBarDelegate和textFieldShouldClear替代方案
EN

Stack Overflow用户
提问于 2012-08-18 03:25:42
回答 2查看 707关注 0票数 3

UITextFieldDelegate有一个- (BOOL)textFieldShouldClear:(UITextField *)textField方法,当用户单击那个小x图标时将调用该方法。

我在UISearchBarUISearchBarDelegate上找不到类似的东西。有没有其他方法可以确定按钮/图标是否在UISearchBar中被单击过

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-18 03:52:45

您可以使用:

代码语言:javascript
复制
searchBar:textDidChange:

根据Reference,当按下X以清除该字段时,也会调用该函数。

票数 3
EN

Stack Overflow用户

发布于 2012-08-18 03:55:58

这样如何(注意讨论的句子):

代码语言:javascript
复制
searchBar:textDidChange:
Tells the delegate that the user changed the search text.

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
Parameters
searchBar
The search bar that is being edited.
searchText
The current text in the search text field.
Discussion
This method is also invoked when text is cleared from the search text field.

Availability
Available in iOS 2.0 and later.
Declared In
UISearchBar.h
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12011986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档