1
votes

There is this "undo" key on the iPad keyboard.

I have a UITextField *textField where, textField.placeholder = @"Input";

Assumed that textField is not empty (textField.text = @"Something";), as I touched the textField and it became firstResponder,

1, Backspace all the string in textField (placeholder is shown) 2, Type something else 3, Backspace everything again (placeholder is shown) 4, press "undo" key

Result: The textField.placeholder is shown with textField.text overlapping it. Plus, the UITextFieldDelegate (shouldChangeCharactersInRange and UITextFieldTextDidChangeNotification) is not being called.

Is anyone facing the same problem? Is it somehow an iOS bug?

1

1 Answers

0
votes

Here are some steps to follow, just confirm whether you have done in this way only.

  1. IBOutlet connection to textfield object with nib file
  2. Set delegate property for textfield in nib file to file owner
  3. In .h file implements
  4. In .m file implement these methods:
    • (void)textFieldDidBeginEditing:(UITextField *)textField
    • (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

So when you start editing, first method gets called. And after that for each and every update in textfield second method gets called.

Use breakpoints it will help you to catch the exact scenario.