In iOS 5, if I set allowsMultipleSelectionDuringEditing
to YES on a UITableView then swipe-to-delete no longer works. The built-in Mail app supports both swipe-to-delete and multiple selections in edit mode, and I'd like to do likewise. How do I achieve this?
The trick is to set allowsMultipleSelectionDuringEditing
to YES on entering edit mode and set it back to NO on exiting edit mode. This way, both swipe-to-delete and multiple selections in edit mode work.
If you've subclassed UITableViewController
(which you probably have), then you can simply do this:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated { // Set allowsMultipleSelectionDuringEditing to YES only while // editing. This gives us the golden combination of swipe-to-delete // while out of edit mode and multiple selections while in it. self.tableView.allowsMultipleSelectionDuringEditing = editing; [super setEditing:editing animated:animated]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With