UITextFieldDelegate有一个- (BOOL)textFieldShouldClear:(UITextField *)textField方法,当用户单击那个小x图标时将调用该方法。
我在UISearchBar或UISearchBarDelegate上找不到类似的东西。有没有其他方法可以确定按钮/图标是否在UISearchBar中被单击过
发布于 2012-08-18 03:52:45
您可以使用:
searchBar:textDidChange:根据Reference,当按下X以清除该字段时,也会调用该函数。
发布于 2012-08-18 03:55:58
这样如何(注意讨论的句子):
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.hhttps://stackoverflow.com/questions/12011986
复制相似问题