无法解除ViewControllerAnimated iOS 9.3

时间:2016-04-02 09:06:47

标签: swift2 uialertcontroller ios9.3

我正在显示UIAlertController并在UIAlertAction我正在解雇视图控制器。它在iOS 9.3之前运行良好。但在iOS 9.3中,它无法正常工作。以下是代码。

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)

1 个答案:

答案 0 :(得分:1)

尝试将断点放在dismissViewControllerAnimated行中,并在按OK时检查它是否到达那里。

如果不是 - 请尝试替换

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

用这个:

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