一、取消第一响应。(可以在增加的手势中,touchesBegan中)
UITapGestureRecognizer*tap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tap:)];[self.viewaddGestureRecognizer:tap];
-(void)tap:(UITapGestureRecognizer*)sender
{
UITextField*textfield=(UITextField*)sender.view;
[textfieldresignFirstResponder];
[onetextresignFirstResponder];
[twotextresignFirstResponder];
[textviewresignFirstResponder];
}
二、self.view endEditing结束编辑模式。(在增加的手势,touchesBegan中)
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
[self.viewendEditing:YES];
//[onetext resignFirstResponder];
//[twotext resignFirstResponder];
//[textview resignFirstResponder];
}
三、点击键盘return键收起键盘。
- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
[textFieldresignFirstResponder];
returnYES;
}