TextField becomeFirstResponder Issue for tab key(K

2019-06-15 18:30发布

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.

1条回答
来,给爷笑一个
2楼-- · 2019-06-15 18:51

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.

查看更多
登录 后发表回答