7
votes

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.

2
while I can handle criticism well, I think that downvoting a question that has taken some time to ask, and that I've done some digging about it without saying why is just plain cruel. - David Conde
Upped it back to zero (I didn't down it). But don't worry about criticism from strangers. It's not a bad question if you're not a pro. - QED
thanks psoft! I actually think that criticism is a good thing but only when properly justified! Thanks for the help - David Conde

2 Answers

10
votes

- (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.

1
votes

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.