IOS在textFiled上面设置事件,实现轻触 Return 调用事件关闭键盘
- (void)viewDidLoad { myTextField =self.myTextField; [self.myTextField addTarget:self action:@selector(backgroundTap:) forControlEvents:UIControlEventEditingDidEndOnExit]; } - (IBAction)backgroundTap:(id)sender { [myTextField resignFirstResponder]; }