- (void)viewDidLoad
{
[super viewDidLoad];
self.singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAnywhere:)];
self.singleTapRecognizer.numberOfTapsRequired = 1;
self.singleTapRecognizer.cancelsTouchesInView = NO;
}
-(void)didTapAnywhere: (UITapGestureRecognizer*) recognizer {
//[textField resignFirstResponder];
[self.view endEditing:YES];
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{
NSLog(@"add gesture recg");
[self.view addGestureRecognizer:singleTapRecognizer];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
NSLog(@"remove gesture recg");
[self.view removeGestureRecognizer:singleTapRecognizer];
}