Disabling the 'Search' button in the searchbar keyboard [duplicate]

左心房为你撑大大i 提交于 2020-01-15 23:36:48

问题


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:


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
     }
}


来源:https://stackoverflow.com/questions/11020799/disabling-the-search-button-in-the-searchbar-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!