How to recognize the text above the text after it became the first responder?

When the UITextView is listening, I want it to continue to work as the first responder, but I need to fire other events as well. UITapGestureRecognizer works long before the UITextView is not the first responder, but after it is focused, the crane is no longer recognized.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapRecognized:)]; singleTap.numberOfTapsRequired = 1; [txtView addGestureRecognizer:singleTap]; [singleTap release]; -(IBAction)singleTapRecognized:(id)sender { //Does not enter here with a tap after txtView is first responder } 
+4
source share
2 answers

Use the following code in the ViewDidLoad() method and remember to enable

 [yourTextView setUserInteractionEnabled:YES] UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:SEL(textViewTapped:)]; [gestureRecognizer setNumberOfTapsRequired:1]; [yourTextView addGestureRecognizer:gestureRecognizer];` 
+4
source

You must implement the following method for your gesture recognizer delegate:

 -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer { return YES; } 
0
source

Source: https://habr.com/ru/post/1436717/


All Articles