Swift tableviewcell左滑删除

来源:互联网 发布:模糊pid控制算法程序 编辑:程序博客网 时间:2024/05/16 15:31

设置哪一组哪一行可滑动

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool{        if indexPath.section==1 {            if indexPath.row != 0 {                return true            }else{                return false            }        }else{            return false        }            }

 func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String?{        return "删除"    }    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)    {                if editingStyle == UITableViewCellEditingStyle.delete {                        self.diagnoseArr.removeObject(at: indexPath.row-1)            //刷新tableview            tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)        }    }