PDA

View Full Version : IPhone: UITextField - how to set certain action for return key on keyboard




pashik
Jul 16, 2008, 08:06 AM
Hi.

There is view with 2 UITextField and login button.
When user is in password textbox keyboard is shown with return key set as "Go".
How i can set that return key to make action from Login button so user don't need to close keyboard and touch Login button?

Thanx in advance for reply.



white89gt
Jul 16, 2008, 08:08 AM
You have to set up a UITextField delegate to handle what you're talking about. I don't have any code that I can post up since I'm at work. I could post something later, though.

pashik
Jul 16, 2008, 08:39 AM
You have to set up a UITextField delegate to handle what you're talking about. I don't have any code that I can post up since I'm at work. I could post something later, though.

It would be great if u show some code.

pashik
Jul 17, 2008, 04:07 AM
here is code which works:

// UITextFieldDelegate

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[theTextField resignFirstResponder];
if(theTextField = myPasswordTextField)
[self onLoginButtonClicked];
return YES;
}