一,UITextView取消第一响应
UITextView *editTextView = [[UITextView alloc] init];
self.editTextView = editTextView;
editTextView.returnKeyType = UIReturnKeyDone;
[imageView addSubview:editTextView];
editTextView.delegate = self;
#pragma mark - UITextView Delegate Methods
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
return YES;
}
二,UITextField取消第一响应
field.returnKeyType = UIReturnKeyDone;
[field addTarget:self action:@selector(onKeyBoardDown:) forControlEvents:UIControlEventEditingDidEndOnExit];// 取消第一响应
-(void)onKeyBoardDown:(id)sender{
[sender resignFirstResponder];
}
或者
或者
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}