美文网首页
swift 简单的左滑删除

swift 简单的左滑删除

作者: Dove_iOS | 来源:发表于2019-04-30 15:34 被阅读0次
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool{
    return true
}

override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    let delete = UITableViewRowAction(style: .normal, title: kLocal(keys: "delete", comment: "删除")) { action, index in
        let mes = self.kLocal(keys: "archive_delete_archive", comment: "確認刪除?")
        let cancel = self.kLocal(keys: "cancel", comment: "取消")
        let def = self.kLocal(keys: "ok", comment: "確定")
        let alertController = UIAlertController(title: nil, message: mes, preferredStyle: .alert)
        let cancelAction = UIAlertAction(title: cancel, style: .cancel, handler: nil)
        let okAction = UIAlertAction(title: def, style: .default,
                                     handler: {
                                        action in
                                        print("点击了确定")

        })
        alertController.addAction(cancelAction)
        alertController.addAction(okAction)
        self.present(alertController, animated: true, completion: nil)
    }
    delete.backgroundColor = UIColor.red
    return [delete]
}

相关文章

网友评论

      本文标题:swift 简单的左滑删除

      本文链接:https://www.haomeiwen.com/subject/mwjvnqtx.html