Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swipe to delete not working while on edit mode

I'm having the following problem.

I have an app using a UITableView with a custom UITableViewCell. Because of the specs of the app, I need it to be in edit mode always, so on the viewDidLoad I wrote this:

- (void)viewDidLoad
{
    MainTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"compose_background.png"]];
    [MainTableView setAllowsSelectionDuringEditing: TRUE];
    [MainTableView setEditing: TRUE];

    [super viewDidLoad];    
}

Also, I've implemented the following methods:

- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView  editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
- (BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

And several more, but the problem persists and when I swipe a cell the delete button doesn't shows up. Any pointers would be highly appretiated.

like image 554
David Conde Avatar asked Feb 26 '12 17:02

David Conde


2 Answers

- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath must return UITableViewCellEditingStyleDelete for each row you want to delete. Swipe-to-delete is disabled in favor of this method when in editing mode.

like image 186
QED Avatar answered Oct 06 '22 01:10

QED


I don't think there is anyway for the standard swipe to delete to work while the table view is in editing mode, you'd have to respond to gestures and add your own delete button.

like image 42
Ell Neal Avatar answered Oct 05 '22 23:10

Ell Neal