开发者

Search bar delegate - difference between searchBarShouldBeginEditing / searchBarTextDidBeginEditing?

开发者 https://www.devze.com 2022-12-11 16:32 出处:网络
What\'s the difference开发者_运维问答 between them? In my experimentation, they seem to get called during the same action - once the user taps the search bar to bring up the keyboard. This is despite

What's the difference开发者_运维问答 between them? In my experimentation, they seem to get called during the same action - once the user taps the search bar to bring up the keyboard. This is despite the user not having editing the actual text yet. Which seems to call searchBar:textDidChange. But that gets called for each change, not just once at the beginning. Which means I have to write more code to duplicate how the Search Bar behaves in Google Maps.

OK, so that turned more into venting - but maybe I'm missing something. Are there cases in which searchBarShouldBeginEditing is called but not searchBarTextDidBeginEditing - or vice-versa?


Any message with "should" in the name is expected to return a boolean. If that's false, then, in this case, editing is not begun, and the search bar does not becomeFirstResponder (ie, the user taps on it, but no keyboard appears for editing).

0

精彩评论

暂无评论...
验证码 换一张
取 消