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.
如何检测用户何时按下通用搜索栏中的空文本字段?
1)您应该设置文本字段(UITextField或UISearchBar)的委托属性。
UITextField
UISearchBar
2)您应该在委托以下方法中实现:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
或者
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
每当用户想要输入文本时都会调用它。