Preface
These past few days I ran into a problem: when a pan gesture is applied to a view, I couldn’t distinguish its direction.
So I found the answer on StackOverflow and documented it here.
1
2
3
4
5
6
7
8
9
10
11
12
13
- (void)panRecognized:(UIPanGestureRecognizer *)rec
{
CGPoint vel = [rec velocityInView:self.view];
if (vel.x > 0)
{
// user dragged towards the right
}
else
{
// user dragged towards the left
}
}