maxhud maxhud - 7 months ago 92
iOS Question

Add swipe gesture to UITableView

How would I make it so that one gesture anywhere on a UITableView would do something?

Not just within one cell, but anywhere on the screen (a horizontal swipe)?

- (void)viewDidLoad
    [super viewDidLoad];
    UISwipeGestureRecognizer *recognizer;
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    //There is a direction property on UISwipeGestureRecognizer. You can set that to both right and left swipes
    recognizer.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft;
    [tableView addGestureRecognizer:recognizer];
    [recognizer release];



Just return UITableViewCellEditingStyleNone in your tableView:editingStyleForRowAtIndexPath: method.