I have a UITableView. I have added to this table a UIGestureRecognizer that looks for a swipe on a cell, and enables editing on that table if it detects a swipe. When I swipe right, it does indeed enable editing on the table. However, when I swipe left, I get the default red delete button appear on the right side of the cell. How can I disable this default behavior, and make it so that if I swipe left OR right, I get editing on either way?
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
foldersTable.editing=YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[foldersTable addGestureRecognizer:recognizer];
[recognizer release];
}
Just return UITableViewCellEditingStyleNone
in your tableView:editingStyleForRowAtIndexPath:
method.
There is a direction property on UISwipeGestureRecognizer. You can set that to both right and left swipes:
recognizer.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With