Skip to content

Instantly share code, notes, and snippets.

@codesburner
Forked from xoebus/gist:343792
Created April 4, 2011 10:39
Show Gist options
  • Save codesburner/901457 to your computer and use it in GitHub Desktop.
Save codesburner/901457 to your computer and use it in GitHub Desktop.
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:[self view]];
CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) {
[label setText:@"Horizontal swipe detected"];
[self performSelector:@selector(eraseText) withObject:nil afterDelay:2];
} else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance) {
[label setText:@"Vertical swipe detected"];
[self performSelector:@selector(eraseText) withObject:nil afterDelay:2];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment