Detect UISearchBar focus on the text field

纵饮孤独 提交于 2019-12-07 03:52:12

问题


Is there a way to detect if a user has click on the searchbar textfield and the keyboard has appear ?


回答1:


From the docs,

  • searchBarTextDidBeginEditing:
  • searchBarCancelButtonClicked:



回答2:


If you are implementing UISearchBarDelegate, the first method that should be called is:

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {  
    //do stuff
    return YES;  
}  

Here's the class reference:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISearchBarDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UISearchBarDelegate/searchBarShouldBeginEditing:




回答3:


Your searchbar delegate should receive a searchBarTextDidBeginEditing: message.



来源:https://stackoverflow.com/questions/2095909/detect-uisearchbar-focus-on-the-text-field

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