I would like to present the user with a simple UIAlertController with one of the parameters that starts closing the parent view controller. Here is the code I'm using:
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Close View", style: UIAlertActionStyle.Destructive, handler: {
action in
self.dismissViewControllerAnimated(true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "CANCEL", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
This has no effect. After executing the "Close View" handler, the display controller that presents the warning still exists.
I also tried self.navigationController?.dismissViewControllerAnimated(true, completion: nil)UIAlertAction in the action block, but that didn't work either.
source
share