Mingebag
Mingebag

Reputation: 758

How can I catch the clear button in a UITextField

Is it possible to catch a clear button method from a UITextField somehow and then and give it more things to do like clear annotations on a map etc ?

On which method I need to catch to additional with the clear button ?

Thanks for help and fast answer

Upvotes: 0

Views: 65

Answers (1)

Wain
Wain

Reputation: 119021

You can set yourself as the text field delegate and implement textField:shouldChangeCharactersInRange:replacementString:. If the range is the full range of the textField.text and the replacement string is equal to @"" then it is a clear operation.

Note that the user manually selecting all text and hitting backspace on the keyboard will have the same result.

Upvotes: 2

Related Questions