私は初心者レベルのプログラマーです。アラートのボタンにアクションを追加しようとしていますが、機能しません。アラート ボタンを選択してラベルのテキストを変更できるかどうかをテストしたいだけですが、機能しません。もちろん、アラートとボタンはよく見えますが、ボタンをクリックしても何も起こりません。
@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"
}
}