我正在显示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)
答案 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)
}