gpt4 book ai didi

ios - UIAlertView 使应用程序崩溃

转载 作者:可可西里 更新时间:2023-10-31 23:44:33 26 4
gpt4 key购买 nike

我正在尝试在我的 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)
}

最佳答案

不确定您的问题是什么。您可以通过消除空闭包并尽可能缩短参数来简化代码,如下所示 (Xcode 7b6)。但我不认为这是你的问题。相反,您应该显示调用此函数的代码。

var alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(alert, animated: true, completion: nil)

关于ios - UIAlertView 使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32486245/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com