在UITableView上显示重新排序控件时启用“滑动到删除”

问题描述 投票:13回答:1

我希望允许重新排序UITableViewCells并通过滑动删除删除,但不能通过红色删除圈。

- (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;
}

此外,我已经尝试禁用编辑模式并调用-[UITableViewCell setShowsReorderControl:YES]没有运气。

Image (来源:booleanmagic.com

iphone uitableview uikit gesture
1个回答
2
投票

我想你必须做一些自定义触摸事件拦截。

在英语中:如果手指移动,x距离,水平跨越单元格,仅在该单元格中,则显示删除控件。

不知道如何关闭左边的圆圈,但我认为这是一个像“显示重新排序控制”的属性

© www.soinside.com 2019 - 2024. All rights reserved.