Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何禁用/启用 UISearchBar 键盘的搜索按钮?
我们可以禁用搜索栏键盘上的“搜索”按钮吗?我想在用户在搜索栏中输入 3 个字符后启用它。
显然,你不能那样做。你需要实现 UISearchBar 的委托
- searchBarSearchButtonClicked:
您可以在您的委托中添加一个条件,例如:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar1 { if ([searchBar.text length] < 3){ return; } else { // Do searching here or other stuffs } }