Closed Sun3 closed 10 years ago
I confirm this is a bug. The problem is related to the data source forwarding code but at first glance I'm not able to tell what it is.
I don't use the default swipe to delete feature, so it might take me a while to fix this. Please don't hesitate to submit a pull request if you find a fix.
When I add below code to the HPReorderTableView class it allows to swipe and the Delete button appears, but once you tab the Delete Button it runs the commitEditingStyle
in the HPReorderTableView class instead of the code in my form to run because it now runs in the class instead :)
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
NSLog(@"Delete");
; // Delete.
}
Thanks @Sun3! I'll give it a try later this week.
ps: I just re-read my last sentence and it sounds so unclear. Here is what I was trying to say.
Once you place the commitEditingStyle
in the HPReorderTableView class, the commitEditingStyle
in the xib class does not run because the HPReorderTableView class runs it first.
Thanks.
You can now use HPReorderAndSwipeToDeleteTableView
to have both reordering and swipe-to-delete.
The problem was that UITableView
enables swipe-to-delete only if the data source implements tableView:commitEditingStyle:forRowAtIndexPath:
and checks this at initialisation time. Which in my opinion is a horrible design decision. Since HPReorderTableView
uses data source forwarding, it either has to support swipe-to-delete, or not.
Given that swipe-to-delete is disabled by default in UITableView, I choose to keep HPReorderTableView
without support for swipe-to-delete and provide a separate class HPReorderAndSwipeToDeleteTableView
for those who need. The code documentation has been updated accordingly.
That is great, thanks. I tested and it works great...
I have a question, now that I am using HPReorderTableView the swipe to show the Delete Button no longer works.
Is there a way to enable it again? I already tried below.
Thank you