Xcode 4.3 add action for keyboard return key

How to make a return key on the keyboard to perform an action (IBAction).

+4
source share
3 answers

well just just add:

- (BOOL)textFieldShouldReturn:(UITextField *)textField{ [self yourButtonName:nil]; } 
+6
source

Deploy UITextFieldDelegate:

 @interface yourClass : UIViewController<UITextFieldDelegate> 

Use the delegate method:

 - (BOOL)textFieldShouldReturn:(UITextField *)textField{ //do whatever you need here //maybe you have several textFields, so first check which one was hit the return key: if(textField == outlet_to_your_textField_1){ //do this } else if(textField == outlet_to_your_textField_2){ //do that } else if .... blablabla and so on return YES; } 
+2
source

This is what I process. When I press Return Key on the iPhone keyboard, the soft keyboard returns from the text view. There are three easy ways to handle the keyboard here.

  • The keyboard returns when a button is pressed.
  • The keyboard returns when the user presses the Return or Done button on the keyboard.
  • The keyboard will return when the user touches the screen / background view.

Soft Keyboard Processing in iPhone Tutorial

Hope this helps you.

0
source

All Articles