1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

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

Discussion in 'iPhone/iPad Programming' started by pashik, Jul 16, 2008.

  1. macrumors member

    #1
    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.
     
  2. macrumors regular

    #2
    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.
     
  3. macrumors member

    #3
    It would be great if u show some code.
     
  4. macrumors member

    #4
    here is code which works:
    Code:
    // UITextFieldDelegate
    
    - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    	[theTextField resignFirstResponder];
    	if(theTextField = myPasswordTextField)
    	   [self onLoginButtonClicked];
    	return YES;
    } 
    
     

Share This Page