-
-
Save anka/402a754e454f5b25a244 to your computer and use it in GitHub Desktop.
iOS handle swipe gestures on a UITableView
This file contains 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)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