0

I am showing an UIAlertController and in UIAlertAction I am dismissing view controller. It was working fine prior to iOS 9.3. But in iOS 9.3 it is not working. Following is the code.

let alertController = UIAlertController(title: "Logged In Successfully", message: "asda", preferredStyle: .Alert)

 // Create the actions
    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { UIAlertAction in
                            self.dismissViewControllerAnimated(true, completion: nil)
                        }

                        // Add the actions
                        alertController.addAction(okAction)

                        // Present the controller
                        self.presentViewController(alertController, animated: true, completion: nil)
Saqib Omer
  • 5,387
  • 7
  • 50
  • 71

1 Answers1

1

Try to put breakpoint in the dismissViewControllerAnimated line, and check if it's getting there when you press OK.

If it's not - try to replace

UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { UIAlertAction in
                            self.dismissViewControllerAnimated(true, completion: nil)
                        }

with this:

UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { _ in
                            self.dismissViewControllerAnimated(true, completion: nil)
                        } 
Witterquick
  • 6,048
  • 3
  • 26
  • 50