[Tips] Action with Enter Key

How to assign action to Enter Key.

ViewController.h
//Delegate

@interface ViewController : UIViewController<UITextFieldDelegate>
@property (weak, nonatomic) IBOutletUITextField *TextBox;
@end

//set textfield’s delegate

ViewController.m

– (BOOL)textFieldShouldReturn:(UITextField *)textField {
   //some action here
  // [self hoge];
   //distinct textfield
   //  if(textField.tag == 1)
   //  else if(textField. == 2)
    returnYES;
}

We hope this article help you :)