【发布时间】:2016-05-17 18:26:45
【问题描述】:
所以,我有一个视图控制器,上面有许多文本字段。前两个文本字段需要在提交前输入文本。我检查前两个文本字段并显示警报控制器以防它们为空。
let alertController = UIAlertController(title: "Error", message:
"Please enter some text.", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default,handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
只要在尝试提交表单之前关闭键盘,就可以正常工作。但是,如果键盘仍然显示,则应用程序崩溃并出现致命的“错误:在展开可选值时意外发现 nil”
这里发生了什么?
【问题讨论】:
-
我认为崩溃与您提供的代码没有任何关系。您能否显示更多代码和/或崩溃日志?
标签: ios swift keyboard uialertview uialertcontroller