I have a text field and a button. When the button is pressed, it calls a routine. I want the textfield end on exit to call the same routine without having to duplicate the code. ViewController.h is below
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityind;
@property (weak, nonatomic) IBOutlet UITextField *search;
- (IBAction)calculate:(id)sender;
@end
In ViewController.h implement UITextFieldDelegate like so:
and then use the method
and call your IBAction and resignFirstResponder, I would also auto-enable return key.