禁用' Search'搜索栏键盘中的按钮 [英] Disabling the 'Search' button in the searchbar keyboard

查看:47
本文介绍了禁用' Search'搜索栏键盘中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何禁用/启用UISearchBar键盘的搜索"按钮?

我们可以为搜索栏禁用键盘上的搜索"按钮吗?我想在用户在搜索栏中输入3个字符后启用它.

Can we disable the 'Search' button in the keyboard for a search bar? I want to enable it after user enters 3 characters in the search bar.

推荐答案

显然,您不能这样做.您需要实现UISearchBar的委托

Apparently, you can't do that. You need to implement UISearchBar's delegate

- searchBarSearchButtonClicked:    

您可以在您的代表中添加一个条件,例如:

You can just add a condition in your delegate like:

 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar1 {
     if ([searchBar.text length] < 3){
          return;
     }
     else {
          // Do searching here or other stuffs
     }
}

这篇关于禁用&amp;#39; Search&amp;#39;搜索栏键盘中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆