0

I have a situation where I need to have a "backspace" key press event inside a textfield. Is there a direct method to use this event, or do I have to implement the textfield delegate and apply some logics.

Xavi Valero
  • 2,047
  • 7
  • 42
  • 80

1 Answers1

1

You don't have to use a delegate essentially. You can set up a notification like below,

[[NSNotificationCenter defaultCenter] addObserver:self
          selector:@selector(handleTextFieldChanged:)
              name:UITextFieldTextDidChangeNotification
            object:searchTextField];

and you can handle the change by implementing handleTextFieldChanged.

This may help Detect backspace in UITextField

Community
  • 1
  • 1
sElanthiraiyan
  • 6,000
  • 1
  • 31
  • 38