1

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.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
wagashi
  • 894
  • 3
  • 15
  • 39

1 Answers1

2

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];
Eugene
  • 10,006
  • 4
  • 37
  • 55
  • It says MainViewController (which is a UIViewController) ma not resond to your latter function. – wagashi Nov 06 '11 at 14:18
  • Because your view controller needs to conform to that protocol first. Read about what the delegation is from this post http://stackoverflow.com/questions/1051842/simple-delegate-example You might also want to read a few tutorials on adopting your classes to delegation protocols. This one for example http://www.roostersoftstudios.com/site/2011/simple-delegate-tutorial-for-ios-development – Eugene Nov 06 '11 at 14:23