Search code examples
objective-ciosuigesturerecognizeraccessoruiswipegesturerecognizer

How to access the 'direction' property of a UISwipeGestureRecognizer?


Possible Duplicate:
Get swipe direction in Cocoa

In my program I have created a UISwipeGestureRecognizer in a header file and configured its directions to be UISwipeGestureRecognizerDirectionLeft and UISwipeGestureRecognizerDirectionRight in the implementation file. I have set it to call a method called handleSwipe when the gesture is recognized. It successfully calls this method, but when I try to determine the direction of that gesture recognizer using its direction property it does not give me a value. Why so?


Solution

  • You cannot use one gesture recognizer to recognize two different gestures. Create two gesture recognizers, one in either direction and point them to handleSwipLeft and handleSwipeRight (that then calls handleSwipe:withDirection: or something).