I am creating a login screen for my application, and I want the return button to say “Next” when there is a field that is not yet complete, and it should say “Go” when all the fields are filled (I'm talking about UITextFields).
The code below works great in that it shows Next and Go at the right moments. But whenever it changes from "Next" to "Go", the next brief on the keyboard is ignored. When he says “Go,” and I clear the text box with a backward stroke, there is no such problem, and it shows “Next” as it should. It is almost like an old keyboard still there and disappears after listening.
My question is: what is the source of this problem and more importantly, how do I get rid of this keyboard freeze?
UITextField *theSender = (UITextField *)sender;
if (allTextFieldsAreFilled) {
if (theSender.returnKeyType!=UIReturnKeyGo) {
theSender.returnKeyType = UIReturnKeyGo;
[theSender resignFirstResponder];
[theSender becomeFirstResponder];
}
} else {
if (theSender.returnKeyType!=UIReturnKeyNext) {
theSender.returnKeyType = UIReturnKeyNext;
[theSender resignFirstResponder];
[theSender becomeFirstResponder];
}
}
This code is called every time the value of one of the three UITextFields changes, therefore it is an IBAction associated with the Editing Changed event.
Thanks in advance for your help!
EDIT
I found out that this will happen only if the text field is configured for protection (password). When it is not configured for protection, it will not freeze, and my code works fine! The problem is that changing the “Go” button usually occurs when the “protected” text field is a responder. So this does not change anything in this problem.
source
share