在搜索栏键盘中停用“搜索”按钮 [英] Disabling the 'Search' button in the searchbar keyboard

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

问题描述


可能重复:

如何禁用/启用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
     }
}

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

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