Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Swipe-to-delete while showing reorder controls on UITableView

I am looking to allow reordering of UITableViewCells and deleting via swipe to delete, but not via the red delete circle.

- (void)loadView
{
    [super loadView];
    [table setEditing:YES animated:NO];
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Perform delete here
    }
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
    // Perform move here
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

Additionally, I've tried disabling the edit mode and calling -[UITableViewCell setShowsReorderControl:YES] with no luck.

Image
(source: booleanmagic.com)

like image 797
rpetrich Avatar asked Sep 17 '09 00:09

rpetrich


1 Answers

I think you'll have to do some custom touch event interception.

In english: if finger moved, x distance, horizontally across cell, in that cell only, then show delete control.

Not sure how to turn off the circles to the left, but I do think it's a property like "shows reorder control"

like image 99
JoePasq Avatar answered Nov 08 '22 21:11

JoePasq