How to Implement Swipe Left to Right in UITableView Cell similar to iOS Mail
I usually implement it at the table level.
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(leftSwipe:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.tableView addGestureRecognizer:recognizer];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(rightSwipe:)];
recognizer.delegate = self;
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.tableView addGestureRecognizer:recognizer];
}
You then have control of the direction and can customize at will
- (void)leftSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
//do you left swipe stuff here.
}
- (void)rightSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
//do you right swipe stuff here. Something usually using theindexPath that you get that way
CGPoint location = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
}
Credit goes to Jade Mind
I've found similar solutions but only for a gesture of swiping from right to left.
SWTableViewCell has all the options you might want.
While dequeing a cell just set up left/right set of buttons as needed.
cell.leftUtilityButtons = [self leftButtons];
cell.rightUtilityButtons = [self rightButtons];
cell.delegate = self;
And by setting the view controller as its delegate, you can listen to the button clicks. Full details on how to implement are in that link
Ex 1:
Ex 2:
In case you are looking for buttons stacked vertically check out this.