ios – UITableViewCell,显示滑动式删除按钮,无需滑动

我搜索几篇文章,但我找不到我要找的东西.基本上,我想在每一行显示删除按钮,但我不想使用UITableView.editing属性.
因为它看起来像这样;

将有“编辑”按钮.当用户点击它时,删除按钮看起来像滑动式.

有没有机会显示这样的删除按钮;

也许有一些方法可以解决它.否则,我将为此创建自定义视图.

谢谢你的建议.

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return YES if you want the specified item to be editable.
    return YES;
}

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

       //Do something... 
    }
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
           editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewCellEditingStyleDelete;

}

解决方法

>添加布尔属性:@property BOOL didPressEdit;
>将UIButton添加到UITableViewCell
>当按下编辑时,didPressEdit变为TRUE并且UITableView重新加载,这样cell.deleteButton.hidden =!didPressEdit;这使得所有删除按钮都可用
>按delete时,从数据源数组中删除对象,重新加载tableview

希望这可以帮助

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...