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

跟風遠走 提交于 2019-12-03 09:06:47

问题


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.


(source: booleanmagic.com)


回答1:


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"



来源:https://stackoverflow.com/questions/1436153/enabling-swipe-to-delete-while-showing-reorder-controls-on-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!