0

我正在展示一个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)
4

1 回答 1

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)
                        } 
于 2016-04-02T09:13:38.593 回答