Reputation: 33978
When I set the text of a UITextField programmatically, the EditingChanged action is not sent to my view controller, the action is only sent when the user changes the text through the keyboard.
However, when I call becomeFirstResponder() on a text field, it does send the EditingDidBegin action. So I can't tell if editing began because the user tapped on the UITextField, or because I did it programmatically. Do you know how I can easily distinguish between the two?
I'm looking for a way to know when the user taps in a UITextField and only when the user taps on it, not when becomeFirstResponder is called on it. Do you know of one?
Upvotes: 0
Views: 160
Reputation: 535890
when I call
becomeFirstResponder()
The secret is that when you call becomeFirstResponder()
, you call it. Your code is running. You are in control. You can do whatever you want.
So if you need your EditingChanged handler to know that you called becomeFirstResponder()
, you simply have to make a notation of this fact beforehand. For example, you could have a Bool property justCalledBecomeFirstResponder
which you set to true
just before calling becomeFirstResponder()
. Now your EditingChanged handler has only to examine (and possibly reset to false
) this Bool property before proceeding.
Upvotes: 2