이것은 생성하려고 시도했지만 작동하지 않는 코드입니다. 인쇄 선을 처음 표시 한 다음 '경고'를 만듭니다. 예를 선택하면 iit이 행을 삭제합니다. 다음 번에 삭제를 클릭합니다.UITableView 행을 삭제하기 전에 경고
func crearAlertaDoble(titulo: String, mensaje: String) {
let alert = UIAlertController(title: titulo, message: mensaje, preferredStyle: .alert)
let botonUno = UIAlertAction(title: "NO!", style: UIAlertActionStyle.destructive, handler: { (action) -> Void in
self.opcionAlertaMensaje = 0
})
let botonDos = UIAlertAction(title: "Si", style: UIAlertActionStyle.default, handler: { (action) -> Void in
self.opcionAlertaMensaje = 1
})
alert.addAction(botonDos)
alert.addAction(botonUno)
present(alert, animated: true, completion: nil)
}
어떤 제안 :
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
crearAlertaDoble(titulo: "¿Seguro que deseas eliminar este calendario?", mensaje: "")
print("opcion elegida: \(opcionAlertaMensaje)")
if (opcionAlertaMensaje == 1) {
objetoContenedor.calendarios.remove(at: indexPath.row) //WIP, MOSTRAR MENSAJE SI ESTA SEGURO
tableView.deleteRows(at: [indexPath], with: .fade)
opcionAlertaMensaje = 2
} else {
}
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
그리고 이것은 경고 코드는?
tableView:commit:forRowAt:
너무 감사에서 그것을를 사용, 그것은 작동합니다! : D –