How to make the return key on the keyboard to perform an action of (IBAction).
well it's simple just add :
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[self yourButtonName:nil];
}
Implement 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With