简体   繁体   English

如何在uisearchbar中关闭键盘?

[英]how to dissmiss keyboard in uisearchbar?

I am working a navigation based application. 我正在使用基于导航的应用程序。 In my application user can search using the UISearchBar. 在我的应用程序中,用户可以使用UISearchBar进行搜索。 Now I want the keyboard to be dismissed after the user hits search (or done not sure which one it is). 现在我希望在用户点击搜索后解除键盘(或者不确定它是哪一个)。 I tried doing the way it is done for UITextField but didn't work. 我尝试按照UITextField的方式进行,但是没有用。 so any help would be appreciated. 所以任何帮助将不胜感激。

thanks, 谢谢,

Hope this helps for anyone that else was looking for this. 希望这有助于其他人正在寻找这个。

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    [sbSearch resignFirstResponder];
}

Using UISearchBarDelegate . 使用UISearchBarDelegate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM