我已在工具栏按钮内的 UIBarButtonItem
内添加了 UISearchBar
按钮。
采用以下形式:
// search bar
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 260, 44)];
UIBarButtonItem *searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];
[searchBar release];
[buttons addObject:searchBarButtonItem];
现在,当我单击 UISearchBar
键盘时出现问题。我想在单击输入或搜索按钮时隐藏键盘。我该怎么做?
最佳答案
实现 UISearchBarDelegate
中的方法:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder];
}
关于iphone - 单击输入按钮或搜索按钮时隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7227128/