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]
}
网友评论