Question

I created a custom UITableViewCell subclass with multiple fields and some other properties. Since I used this new cell in my UITableViewController, the cells do not react on the "swipe to delete" gesture.

To test if I'm missing something in my delegate I added a plain standard UITableView to my xib, hooked up dataSource and delegate and returned a regular UITableViewCell from -tableView:cellForRowAtIndexPath: this enabled the gesture again.

I searched on the net and one suggested to plain implement -layoutSubviews which didn't work too.

Is there something I would have to implement in my subclass?

Was it helpful?

Solution

After hours of searching and not finding anything on the internet, I did a whole day trial and error to find out that in my XIB the Editing was set to Multiple Selection During Editing.

I didn't know that this would disable the "Swipe-To-Delete-Functionallity".

As I need both possibilities (s2d unless editing and multiple selection while editing) I added these two lines in my -toggleEditing: method:

if(![_tableView isEditing]) {
    [_tableView setAllowsMultipleSelectionDuringEditing:YES];    // <----
    [_tableView setAllowdSelectionDuringEditing:YES];            // <----
    [_tableView setEditing:YES animated:YES];
}
else {
    [_tableView setAllowsMultipleSelectionDuringEditing:NO];     // <----
    [_tableView setAllowdSelectionDuringEditing:NO];             // <----
    [_tableView setEditing:NO animated:YES];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top