Disabling the 'Search' button in the searc

2019-08-13 02:41发布

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

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.

1条回答
放荡不羁爱自由
2楼-- · 2019-08-13 03:16

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
     }
}
查看更多
登录 后发表回答