Skip to content

Instantly share code, notes, and snippets.

@anka
Created January 4, 2015 13:43
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 anka/ae9f6ae2409014cd840b to your computer and use it in GitHub Desktop.
Save anka/ae9f6ae2409014cd840b to your computer and use it in GitHub Desktop.
iOS register swipe gesture recognizer for a UITableView
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Your controller title";
//Add a left swipe gesture recognizer
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSwipeLeft:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.tableView addGestureRecognizer:recognizer];
[recognizer release];
//Add a right swipe gesture recognizer
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSwipeRight:)];
recognizer.delegate = self;
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.tableView addGestureRecognizer:recognizer];
[recognizer release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment