I need to use AlertView
because it is also compatible with iOS7.
I tried to make this code in my UITableViewController
:
func alertView(View: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
println("in alertView")
switch buttonIndex {
case 1: println("1")
case 0: println("2")
default: println("nil")
}
}
@IBAction func entryPoint(sender: AnyObject) {
var alert = UIAlertView()
alert.delegate = self
println("Pressed")
alert.title = "Enter Input"
alert.addButtonWithTitle("Done")
alert.addButtonWithTitle("Cancel")
alert.alertViewStyle = UIAlertViewStyle.PlainTextInput
var text = alert.textFieldAtIndex(0)
text?.placeholder = "inserisci"
println(text?.text)
alert.show()
}
But it seems that he can not call his delegate (func alertView()
).
When I try to start the application:
Show AlertView
correctly but when I press the buttons the following happens:
"Done" - nothing happens
"Cancel" - wrote nil
in the log
Thanks.