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

- (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] ,但没有运气。


(来源: booleanmagic.com

有帮助吗?

解决方案

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

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

不确定如何关闭左侧的圆圈,但我确实认为它是“显示重新排序控件”等属性

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top