I am working on a UITextView implementation in which I only want to respond to touches that are in a specific part of the text view.
I have a gesture recognizer attached to the view, and this works fine until I set the view as the first responder, what will I do if the transition point in the view is greater than the value of X and Y.
- (IBAction)textViewTapped:(UIGestureRecognizer *)sender {
CGPoint point = [sender locationOfTouch:0 inView:self.view];
NSLog(@"x ix %f, y is %f", point.x, point.y);
if (point.x > 96 && point.y > 106)
[self.myTextView becomeFirstResponder];
}
The problem is that after she’s set up on the first responder and then resigned by clicking outside this text view, my gesture recognition method is no longer called. If I touch the area that the first responder does not set, my method is called as many times as I click. If I install and then fire the first defendant, he does not respond after the first refusal.
- (IBAction) viewTapped: (UIGestureRecognizer *) sender {
[self.view endEditing: YES];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget: self action: @selector (textViewTapped :)];
[self.myTextView addGestureRecognizer: tap];
NSArray * gestures = [self.myTextView gestureRecognizers];
NSLog (@ "got% d recognizers", [gestures count]);
}
In a simple attempt, if I add a new gesture recognizer after each dismissal, then this works, but obviously is not a good solution.
Any thoughts?
mickm source
share