10

I have a view in XIB where i used several text fields in it. Let say the first text field becomes first responder as soon as the view gets loaded in the window. If i press tab key in my machine's keyboard to navigate to next text field ;apart from the immediate text field, all other text fields are also becomes first responder and the textfield begin editing delegate menthod gets called for all the text fields. What could be the issue ? This will occur not only in simulator when we use machine's keyboard also when we use bluetooth keyboard for a iOS device.

Balaji
  • 261
  • 6
  • 12
  • 1
    I just bumped into same problem. textFieldShouldBeginEditing delegate method can be used to prevent editing, but then question is how to find if textFieldShouldBeginEditing was called because of tab key or taping textField. – Vladimir Jun 22 '12 at 15:14
  • I have also run into the same issue... Seriously why would apple not regsiter the tab key press inside textfield:shouldChangeCharactersInRange:replacementString: – HurkNburkS Feb 12 '14 at 18:42

1 Answers1

4

Pressing of tab key => navigation to next textfield with respect to heirarchy of the textfields in the view.

When u press tab - textfieldshouldbeginediting will be called as many times as you textfields - meaning - 5 textfields => one tab key press, all the 5 instances will be called. When you press tab - textfielddidbeginediting will be called only once with respect to the new textfield's instance - Hence any logic for the textfield is better to be in textfielddidbeginediting delegate method.

These are the default characteristics of the delegate methods and not an issue.

Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
Ashwin G
  • 1,570
  • 1
  • 16
  • 23