Skip to content

Instantly share code, notes, and snippets.

@anka
Created January 4, 2015 13:44
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/402a754e454f5b25a244 to your computer and use it in GitHub Desktop.
Save anka/402a754e454f5b25a244 to your computer and use it in GitHub Desktop.
iOS handle swipe gestures on a UITableView
- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
//Get location of the swipe
CGPoint location = [gestureRecognizer locationInView:self.tableView];
//Get the corresponding index path within the table view
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
//Check if index path is valid
if(indexPath)
{
//Get the cell out of the table view
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
//Update the cell or model
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
- (void)handleSwipeRight:(UISwipeGestureRecognizer *)gestureRecognizer
{
//same code for getting UITableViewCell like before
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment