Skip to content

Instantly share code, notes, and snippets.

@MattFoley
Created June 24, 2013 17:06
Show Gist options
  • Save MattFoley/5851687 to your computer and use it in GitHub Desktop.
Save MattFoley/5851687 to your computer and use it in GitHub Desktop.
Pan direction recognizer.
CGPoint velocity = [panGesture velocityInView:panGesture.view];
if (MAX(ABS(velocity.y), ABS(velocity.x)) == ABS(velocity.y) ) {
//Significant direction is vertical
if (velocity.y > 0) {
//Going Down
NSLog(@"Down");
} else {
NSLog(@"Up");
//Going Up
}
} else {
//Significant direction is horizontal
if (velocity.x > 0) {
//Going Right
NSLog(@"Right");
} else {
//Going Left
NSLog(@"LEFT");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment