Sono programmatore di livello principianti. Sto cercando di aggiungere azioni ai pulsanti su Alert, ma non funziona. Voglio solo verificare se la scelta del pulsante di avviso può modificare il testo nell'etichetta, ma non funziona. Ovviamente riesco a vedere bene l'avviso e i pulsanti, ma non succede nulla dopo aver fatto clic sul pulsante.Come aggiungere un'azione ai pulsanti in Alert in Swift
@IBOutlet var statusLabelAlert : UILabel
var alertTest = UIAlertView()
@IBAction func alertButton(sender : AnyObject) {
alertTest.message = "Select one!"
alertTest.addButtonWithTitle("1st")
alertTest.addButtonWithTitle("2nd")
alertTest.addButtonWithTitle("3rd")
alertTest.title = "Test Alert"
alertTest.show()
}
func alertView(alertView: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){
switch buttonIndex{
case 0:
statusLabelAlert.text = "1st"
case 1:
statusLabelAlert.text = "2nd"
case 2:
statusLabelAlert.text = "3rd"
default:
statusLabelAlert.text = "error"
}
}