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; }
source share