Iphone 自定义UITableView中的删除按钮

Iphone 自定义UITableView中的删除按钮,iphone,xcode,uibutton,customization,Iphone,Xcode,Uibutton,Customization,我有“滑动以删除”表视图单元格的功能。我想自定义删除按钮 这是否可能,以及如何访问“删除”按钮?尝试以下操作: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingS

我有“滑动以删除”表视图单元格的功能。我想自定义删除按钮

这是否可能,以及如何访问“删除”按钮?

尝试以下操作:

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

当用户执行刷卡操作时,将调用此方法

只需将其放在您的CustomCell中即可

- (void)willTransitionToState:(UITableViewCellStateMask)state
    {
        [super willTransitionToState:state];
        if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
        {
            for (UIView *subview in self.subviews)
            {
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"])
                {
                    UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
                    [deleteBtn setImage:[UIImage imageNamed:@"arrow_left_s11.png"]];
                    [[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
                }
            }
        }
    }

您不应该尝试这样做,您不应该更改Apple的默认视图。

如果您只需要更改按钮的标题,您只需要添加TitleForDeleteConfirmationButtonErrorWatIndeXPath方法

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
    return @"NewButtonName";
}

试试这些“铍”,你的建议是创建一个定制电池?但是我已经建立了一个单元格,我宁愿设置一个手势识别器,然后将它作为一个自定义单元格。你想要删除按钮的操作,或者你需要更改删除按钮。请查看我的答案,但确保你需要一个自定义单元格@Spire@Spire,您是如何自定义“删除”按钮的。分享您的答案。好的,那么如何在
//您的代码
部分中调用删除按钮?如何在
UIButtonTypeCustom
中更改它?这是表的内置功能,所以您可以做任何您想做的事情,比如从数组中删除值,例如-[idArray removeObjectAtIndex:indexPath.row];其中idArray是具有ID的NSMutableArray。最后,只需通过调用[tableView reloaddata]重新加载表即可;其中tableView是您的表名。我找到了另一种删除方法,但感谢您的努力。我将在这方面得到更多的教育,因为我将需要它的其他项目。thx有一件事,我不使用自定义单元格,这就是为什么我需要关于如何更改删除外观的信息,使其看起来像轻推按钮。你不应该尝试,你不应该更改苹果的默认视图。你看到了吗?不是真的,你可以做各种各样的自定义用户界面黑客,如果他们添加到产品中,苹果会接受他们。我们一直在做自定义UI。