I am looking for write action for done button in default keyboard,
I just created a loginpage with username and password.
The user fill the textfields when keyboard appears.
I want to submit that username and password to the done button in keyboard, instead of adding another submit button in uiview.
What can I do?
You have to implement UITextFieldDelegate in you controller and then you can add the - (BOOL)textFieldShouldReturn:(UITextField *)textField
method
and you have to do something like this
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == usernameField) {
[passwordField becomeFirstResponder];
} else if (textField == passwordField) {
//HERE THE LOGIN CODE
[textField resignFirstResponder];
}
return YES;
}
where usernameField and passwordField are two IBOutlet linked to the UITextField for username and password. This code checks that if you press the return key when you are writing in username field pass the writing control to password field, and if you are in the password field and you hit return it's time to call your login code. The [textField resignFirstResponder];
dismiss the keyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With