UITextFieldDelegate有一个方法- (BOOL)textFieldShouldClear:(UITextField *)textField
,当用户点击了这个小x
图标时会调用该方法。
我找不到UISearchBar
或UISearchBarDelegate
类似的内容。有没有其他方法可以找出是否在UISearchBar
内点击了该按钮/图标?
答案 0 :(得分:3)
答案 1 :(得分:1)
这个怎么样(并注意讨论句子):
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