In my UITableViewCell subclass I add a pan gesture and in gestureRecognizerShouldBegin
method 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 am getting x=-4.000000 and y=0.000000
How TranslationInView
work, I am trying to wrap my head around it, when I am getting the correct location of cell 0.0 and 0.0 because the first cell will have 0.0 and 0.0, why I need TranslationInView
.
TranslationInView is a method of UIPanGestureRecognizer and it tells you how far the touch moved since it was last reset. It resets when the touch goes down or if you reset it yourself.
For example
- (void) pan: (UIPanGestureRecognizer *) recognizer
{
if ((recognizer.state == UIGestureRecognizerStateChanged)||(recognizer.state == UIGestureRecognizerStateEnded)) {
CGPoint translation = [recognizer translationInView:self];
}
}
The CGPoint traslation gets increased/decreased the distance that the gesture has moved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With