Here is the controller I implemented for running on iOS7:
import UIKit
@objc(StartViewController)
class StartViewController: UIViewController, UIAlertViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
let confirm:UIAlertView = UIAlertView(title: "sdfsdf", message: "sfsff3333", delegate: self, cancelButtonTitle: "cancel")
confirm.alertViewStyle = UIAlertViewStyle.Default
confirm.show()
}
// MARK: UIAlertViewDelegate
func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
println("buttonIndex: "+buttonIndex)
}
func alertViewCancel(alertView: UIAlertView) {
println("cancel")
}
}
It turns out that none of the functions from UIAlertViewDelegate
is ever called even if I set the delegate correctly to self.
When I click on one of the buttons in the alert dialog I got the following output in the console:
0x796d4984
What do I have to do to make the UIAlertViewDelegate
methods being called?
Edit: I also did:
confirm.delegate = self
This does not help.