I'm using a very basic UIAlertController setup with two buttons.
var alert = UIAlertController(title: "Leave player?",
message: "You will not be able to return to this routine after!",
preferredStyle: .Alert)
let cancelAction: UIAlertAction = UIAlertAction(title: "Continue", style: .Cancel) { action -> Void in
println("here")
}
let deleteAction: UIAlertAction = UIAlertAction(title: "Leave", style: .Default) { action -> Void in
println("here")
}
alert.addAction(cancelAction)
alert.addAction(deleteAction)
self.presentViewController(alert, animated: true, completion: nil)
This code is working on the same View with a push segue from a different part of the program. Where the structure is:
(MainView) -push> (View1) -push> (View2) -push> (ThisView)
Now the AlertController popups and the button return the simple text output.
But in the following situation the AlertController popups but clicking button returns nothing, my breakpoint never fires or just checking the console for the text output returns nothing.
(MainView) -modal> (ThisView)
Of Course I tried setting the segue in the second situation to a push segue, but it didn't change anything. So to make no mistake, the AlertController does popup, but the buttons don't respond at all. Can I make a alternative delegate?
Now it just costed me a full day of getting something simple to work. I've tried most tricks like delays or a async block.
Now I'm kind of out of things to try. So please someone enlighten me what I'm doing wrong :)
UPDATE
Embedding the MainView in a navigation controller and changing the segue to a Push segue, makes the button presses respond.. Adding a navigation controller to fix this is something I could consider, but I would like to keep the Modal segue for its animation. Any Ideas?
Temporary solution
For now I'll use the push segue and the navigation controller to solve this behaviour. It is not optimal, ,since this view should behave as a popup and not a push like segue, but it works.