Skip to content

Instantly share code, notes, and snippets.

@stevestreza
Created November 16, 2010 08:36
Show Gist options
  • Select an option

  • Save stevestreza/701590 to your computer and use it in GitHub Desktop.

Select an option

Save stevestreza/701590 to your computer and use it in GitHub Desktop.
How to handle swipe detection on iOS
-(void)setupGestureRecognizer{
UIView *myView = ...;
UISwipeGestureRecognizer *swipeDown = [[[UISwipeGestureRecognizer alloc] init] autorelease];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.numberOfTouchesRequired = 2; // might need this because of the scroll view
[swipeDown addTarget:self action:@selector(handleSwipeDown:)];
[myView addGestureRecognizer: swipeDown];
}
-(void)handleSwipeDown:(UISwipeGestureRecognizer *)swipeDown{
[self hideKeyboard]; // whatever the button does when you tap it, do that here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment