Search code examples
objective-ckeypresssimulate

ios simulate press done/return


I dont want to hide keyboard, but simulate tapping done/return key type, so it will call one of my functions.

UITextFieldInputTraits?

I appreciate if you could direct me in right way.


Solution

  • Use UITextField delegate method:

    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
      [self myFoo];
      return NO;
    }
    

    if you need to simulate tapping return call this function like:

    [self textFieldShouldReturn:nil];