iphone - 禁用搜索栏键盘中的 'Search' 按钮

标签 iphone objective-c ios cocoa-touch uisearchbar

<分区>

Possible Duplicate:
How can I disable/enable UISearchBar keyboard's Search button?

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

最佳答案

显然,您不能那样做。你需要实现 UISearchBar 的委托(delegate)

- searchBarSearchButtonClicked:    

您可以在委托(delegate)中添加一个条件,例如:

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

关于iphone - 禁用搜索栏键盘中的 'Search' 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11020799/

相关文章:

iphone - 一个设备可以在多个 iOS Developer Program Account 中吗?

iphone - 隐藏电影播放器​​中的音量栏

ios - 视频从应用程序上传到 youtube

iphone - 如何使用 subview Controller 模式链接嵌套 View Controller

iphone - "readInBackgroundAndNotify"增加接收器的保留计数

iphone - 更改 UITableview 中按下的特定按钮的图像

objective-c - 在 Cocoa 中以有效的方式提取 NSString 的一部分

ios - 如何将值从 viewControllerA 发送到 viewControllerB?

关于 NSString NSInteger 和方法调用的 Objective-C 问题

ios - 将 1299 显示为 1.2K 而不是 1.3K