Why should shouldReceiveTouch always tell my gesture recognizer that it is listening in the same place?

I have the following code:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch { NSLog(@"%@", NSStringFromCGPoint([recognizer locationInView:self.view])); ... 

Every time I click, I get {0, -64} . No matter where I touch. What am I doing wrong?

+4
source share
1 answer

I think this is the expected behavior because: "This method is called before touching Began: withEvent: is called for the gesture recognizer to be touched again." So, I think this means that the recognizer is not yet aware of its location. To get the location, use the touch argument instead:

 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch { NSLog(@"%@", NSStringFromCGPoint([touch locationInView:self.view])); ... 
+8
source

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


All Articles