Reputation: 63
Is there a way to get the direction of swipe before the scrolling the UIScrollView
?
I tried to add swipe gesture but no luck.
Here is the event I want to handle. If I swipe fast sideways, left or right, and down-ish, I want it scroll else don't scroll. Also I want to get the interval of swipe. Is there a possible way to do those things? Thanks.
Upvotes: 0
Views: 362
Reputation: 4733
You can use UISwipeGestureRecognizer control.Use UISwipeGestureRecognizerDirectionLeft for gettting Direction.
For that have look at this code below:
UISwipeGestureRecognizer *oneFingerSwipeLeft = [[[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(oneFingerSwipeLeft:)] autorelease];
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[[self view] addGestureRecognizer:oneFingerSwipeLeft];
In oneFingerSwipeLeft function you can have the direction. Follow the same process for right swipe.
Upvotes: 1