Created
November 16, 2010 08:36
-
-
Save stevestreza/701590 to your computer and use it in GitHub Desktop.
How to handle swipe detection on iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(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