Skip to content

Instantly share code, notes, and snippets.

@antonio081014
Created August 13, 2015 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonio081014/0ad8b1a0aeba04f92393 to your computer and use it in GitHub Desktop.
Save antonio081014/0ad8b1a0aeba04f92393 to your computer and use it in GitHub Desktop.
A Simple Demo of Using UISwipeGestureRecognizer
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *leftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
leftGesture.direction = UISwipeGestureRecognizerDirectionDown;
[self.tableView addGestureRecognizer:leftGesture];
UISwipeGestureRecognizer *rightGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
rightGesture.direction = UISwipeGestureRecognizerDirectionUp;
[self.tableView addGestureRecognizer:rightGesture];
}
- (void)swipe:(UISwipeGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateEnded) {
switch (gesture.direction) {
case UISwipeGestureRecognizerDirectionUp:
break;
case UISwipeGestureRecognizerDirectionDown:
break;
default:
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment