【发布时间】:2015-09-09 17:54:03
【问题描述】:
我试图在我的 Parse 应用程序上创建一个 UIAlertView,但由于某种原因,每次我运行它时,它都会崩溃,我被带到 ApplicationDelegate,在那里我得到了一个 SIGABRT。这是我的警报代码,我很确定我没有做错任何事情,因为它以前工作过……是因为我正在从 Parse 将数据加载到 tableview 中吗?
func displayAlert(title: String, message: String) {
var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
}))
presentViewController(alert, animated: true, completion: nil)
}
【问题讨论】:
-
您的代码看起来不错。您的崩溃是由其他地方引起的。
-
如果我删除警报,它确实有效。
-
这意味着崩溃的源头在您调用
displayAlert函数的位置附近。 -- 还要检查title或message是否为nil。 -
我试图硬设置标题和消息,以便它们始终是特定的消息并且它仍然崩溃。
标签: ios xcode swift uialertview