views:

1402

answers:

1

Hi,

On the iPhone, I've tried to find a way to trap and act upon the backspace key pressed event. But cannot find a way to do that!! There sure must be one such way documented in the SDK right?

/John

+2  A: 

For your UITextField which is taking the input, set your controller object to be the text field's delegate and implement the

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

delegate method in your controller.

This method should be called for every editing event (keypress). I believe that you should be able to look for a blank replacement string to tell that characters are being removed by the backspace key.

Brad Larson
Hmm.. I guess that could be used. It complicates this method of mine even further though... It's a pity there is no explicit way of getting such an event. Thx!
John Lane