0

It is said that a Swipe Gesture UISwipeGestureRecognizer cannot tell the ending location of the swipe (which is kind of strange), and that we need to use UIPanGestureRecognizer instead, as described in this question: UISwipeGestureRecognizer Swipe length

But using that method, isn't it the same if touchesBegan and touchesEnded is used instead? Is there a reason or advantage to use UIPanGestureRecognizer instead?

Community
  • 1
  • 1
Jeremy L
  • 3,770
  • 6
  • 41
  • 62

1 Answers1

1

You can use either ... depends on your choice. It actually depends on your requirement and what you really want to do. If you want to use UITouch you can go ahead .

Also in the link you provided there is the last answer "You can only do it a standard way: remember the touch point of touchBegin and compare the point from touchEnd."

So touches is a lengthier method whereas using gestures makes your code look less .

IronManGill
  • 7,222
  • 2
  • 31
  • 52
  • i think as in that link, the gesture is handled in one handler, while touchesBegan and touchesEnded require two handlers... but the code inside the handlers add up to about the same in either case? Besides, you don't need to create and add the GestureRecognizer if using touchesBegan. – Jeremy L Sep 20 '12 at 07:18
  • I guess one advantage might be, the maximum number of touches can be set to 1, and the velocity can be checked if it is a Pan, so that a slow dragging isn't considered to be a quick swipe. – Jeremy L Sep 20 '12 at 07:28
  • Yeah you can do that eventually, but anyways slow dragging would be considered as Pan rite not swipe ? – IronManGill Sep 20 '12 at 07:36
  • yeah, maybe a slow dragging shouldn't be considered to be a swipe because swipe is usually a quick action – Jeremy L Sep 20 '12 at 07:55