Possible Duplicate:
Detect backspace in UITextField
I am trying to detect the backspace key envent on my UITextfield which is empty. I saw this but could not figure it out. Any elaborate answer or code snippet would be helpful
Possible Duplicate:
Detect backspace in UITextField
I am trying to detect the backspace key envent on my UITextfield which is empty. I saw this but could not figure it out. Any elaborate answer or code snippet would be helpful
:) just for the title "Detect backspace", where I use
UIKeyboardTypeNumberPad
.I also meet the same question tonight, and following is my code to find it out:
Because with
UIKeyboardTypeNumberPad
, user can only input Number or backspace, so when the length of string is 0, it must be backspace key.Hope the above will do some help.
I've found it not to be possible.
When the UITextField is empty, the following delegate method isn't called.
I conquered this by constantly having a space in the field, and when I detect a backspace and the field only contains a space, I return NO in the delegate method.
Visually, this is as good as the field being empty, and it's a workaround to the delegate method not being called on an empty field.
Hope that helps.