Iphone – Is it possible to programmatically show the red delete button on a UITableViewCell

iphoneuigesturerecognizeruitableview

There are lots of similar questions on here, but none that I think specifically ask this question, which is, is there any way in code to force the red delete button to appear at the right-side of a UITableView row?

The reason I ask is that I'm trying to change the behaviour of a tableview using two UISwipeGestureRecognizers such that:

  • a single-finger swipe invokes a custom action (instead of causing the red delete button to show, which is how it behaves now), and

  • a double-finger swipe invokes the default single-finger swipe behaviour, i.e. causes the red delete button to show.

I have scoured through the SDK docs but I can't find any way of causing that red button to appear, which makes me think that the proposed UI scheme above is impossible to implement without manually creating the red delete button from scratch and trying to make it emulate the built-in one's behaviour.

Any help is much appreciated.

Best Answer

In the doubleFingerSwipe gesture's selector method set one variable and assign as no of row swiped and reload the table . In the

- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == yourVariable) return UITableViewCellEditingStyleDelete;
    else return UITableViewCellEditingStyleNone;
}

I think thats work for ur problem.

Related Topic