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

Discussion in 'iOS Programming' started by pashik, Jul 16, 2008.

  1. macrumors member

    Joined:
    Jul 16, 2008
    #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

    Joined:
    Jan 18, 2006
    #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. thread starter macrumors member

    Joined:
    Jul 16, 2008
    #3
    It would be great if u show some code.
     
  4. thread starter macrumors member

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

Share This Page