#import <UIKit/UIKit.h>@interface ViewController : UIViewController<UITextFieldDelegate>{
IBOutlet UITextField *_textField;
}
- (IBAction)pressButton:(UIButton *)sender;
@end
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_textField.delegate=self;
// Do any additional setup after loading the view, typically from a nib.
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[self pressButton:nil];
return YES;
}
- (IBAction)pressButton:(UIButton *)sender {
if([_textField isFirstResponder]){
[_textField resignFirstResponder];
}
}
@end