Trying to understand TranslationInView

In my UITableViewCell subclass, I add a panorama gesture and in the gestureRecognizerShouldBegin method, which I checked self.frame.origin.x and self.frame.origin.y , both are 0.000000 and 0.000000 and after applying TranslationInView CGPoint translation = [gestureRecognizer translationInView:[self superview]]; I get x=-4.000000 and y=0.000000

How TranslationInView works, I try to circle my head when I get the correct cell location of 0.0 and 0.0, because the first cell will have 0.0 and 0.0, so I need TranslationInView .

+6
source share
1 answer

TranslationInView is a UIPanGestureRecognizer method, and it tells you how far the sensor has moved since the last reset. It resets when the touch drops or you reset yourself.

for instance

 - (void) pan: (UIPanGestureRecognizer *) recognizer { if ((recognizer.state == UIGestureRecognizerStateChanged)||(recognizer.state == UIGestureRecognizerStateEnded)) { CGPoint translation = [recognizer translationInView:self]; } } 

CGPoint Broadcast increases / decreases the distance the gesture moves.

+9
source

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


All Articles