Override Gesture Gesture in UITableView

I have a UITableView. I added a UIGestureRecognizer to this table, which searches for scrolling through the cell and allows you to edit this table if it detects wipes. When I scroll to the right, it really allows editing on the table. However, when I scroll left, I get a red default delete button, displayed 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 anyway?

- (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];

}
+5
source share
3 answers

Just return UITableViewCellEditingStyleNoneto your method tableView:editingStyleForRowAtIndexPath:.

+3

UISwipeGestureRecognizer direction. , :

recognizer.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft;
+3

I use a different way to solve this problem.

NSMutableArray *tableViewGestures = [[NSMutableArray alloc]initWithArray:[self.tableView gestureRecognizers]];
[[tableViewGestures objectAtIndex:2] setDirection:UISwipeGestureRecognizerDirectionLeft];
NSLog(@"directions %@" , [tableViewGestures objectAtIndex:2] );

NSArray *newTableViewGestures = [[NSArray alloc]initWithArray:tableViewGestures];
[self.tableView setGestureRecognizers:newTableViewGestures];

I got tableViewGestures NSArray and reset it.If I want to use SwipeGestureRecognizerDirectionRigth, I just need to set the direction again. It is easy. Correctly?

0
source

All Articles