-2

I have an image which I would like to move around in a rail.

When I put my finger on it, i will only be able to move it up and down, and not from side to side. And how do I make them "stick" at either the top or the bottom? (or both)

Thanks.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ifraaank
  • 122
  • 2
  • 13

1 Answers1

0

Check out the answer(s) here - UIPanGestureRecognizer - Only vertical or horizontal

Just do this for the vertical pan gesture recognizer, it works for me:

 - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer {
     CGPoint translation = [panGestureRecognizer translationInView:someView];
     return fabs(translation.y) > fabs(translation.x); }
Community
  • 1
  • 1
StuartM
  • 6,743
  • 18
  • 84
  • 160