0

I need to use view swipe gesture down, up, left and then right. But on swift UISwipeGestureRecognizer has predeterminate right direction. And I don't know how make this for use other directions.

Opal
  • 81,889
  • 28
  • 189
  • 210
  • http://stackoverflow.com/questions/24215117/how-to-recognize-swipe-in-all-4-directions you can check this page. It worked on me. – slytrkmn Nov 30 '16 at 17:22

1 Answers1

0

You can achieve different swipe direction using code and Storyboard as well.

  1. Using Code

    var swipeLeft = UISwipeGestureRecognizer()
    swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
    //Use following Directions as you need
    //UISwipeGestureRecognizerDirection.Right
    //UISwipeGestureRecognizerDirection.Up
    //UISwipeGestureRecognizerDirection.Left
    
  2. Using Storyboard:

    Select the gesture and in Attribute Inspector select the direction. see the screen shot. enter image description here

Note: You will need 4 different gesture recognisers for 4 directions

Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46