Hi,
I have a login screen with two textfields (username and password). When the user clicks on either textfield, the keyboard appears and everything is fine. However, if the user clicks on the other textfield before clicking Done (on the keyboard) for the first textfield, the text for the username isn't saved. The only way to save the original textfield text is by clicking back on it and selecting Done then.
I would like to disable the other textfield from displaying the keyboard while the first textfield's keyboard is still open, if that makes sense? I know there's ways to stop textfields from being editable but how can I tell when there is already a keyboard open?
Another solution may be to disable the keyboard whenever the user clicks anywhere outside of the textfield? How would I do this?
Here's my code:
textFieldEmail = [[UITextField alloc] initWithFrame:frame];
textFieldEmail.keyboardType = UIKeyboardTypeEmailAddress;
textFieldEmail.returnKeyType = UIReturnKeyDone;
textFieldEmail.tag = 0;
textFieldEmail.delegate = [[UIApplication sharedApplication] delegate];
textFieldPassword = [[UITextField alloc] initWithFrame:frame];
textFieldPassword.keyboardType = UIKeyboardTypeEmailAddress;
textFieldPassword.returnKeyType = UIReturnKeyDone;
textFieldPassword.tag = 1;
textFieldPassword.delegate = [[UIApplication sharedApplication] delegate];
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Thanks!