【发布时间】:2014-09-18 19:58:20
【问题描述】:
我刚刚在 App Store 上发布了我的应用程序,但是我刚刚收到电子邮件并告知我存在崩溃问题。
问题在于警报视图在我的应用程序应该出现时崩溃(仅在 iOS 7 中)。我有一些代码可以解决这个问题,但它似乎不适用于某些 iOS 7 版本。
这是我当前的代码:
@IBAction func resetAllButton(sender : AnyObject) {
//If statement to check whether the modern style alert is available. Prior to iOS 8 it is not.
if let gotModernAlert: AnyClass = NSClassFromString("UIAlertController") {
println("UIAlertController can be instantiated")
var alert = UIAlertController(title: "Start Over", message: "Are you sure you want to start over? This will erase your budget and all transactions.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "I'm sure!", style: UIAlertActionStyle.Default, handler:{ (ACTION :UIAlertAction!)in
self.resetView()
}))
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
else {
println("UIAlertController can NOT be instantiated")
var alertView = UIAlertView()
alertView.delegate = self
alertView.title = "Start Over"
alertView.message = "Are you sure you want to start over? This will erase your budget and all transactions."
alertView.addButtonWithTitle("I'm sure!")
alertView.addButtonWithTitle("Cancel")
alertView.show()
}
}
如何确保我的应用不会在任何版本的 iOS 7 或 8 上崩溃?
【问题讨论】:
-
你知道它在哪里/如何崩溃吗?你有堆栈跟踪、行号或任何控制台输出吗?
-
很遗憾没有。我没有 iOS 7 设备来测试它。它们似乎在 iOS 7.1 上,我显然可以在模拟器上进行测试,但它不会在模拟器上发生。我所知道的是,它是显示任何 UIAlertView 的时候。而且它只在 iOS 7 上。
-
我刚刚有一个 iOS 7.1 设备可以试一试。它在运行从商店下载的应用程序时遇到了同样的问题,但是一旦我通过我的 Xcode 项目运行它,一切正常。
-
现在你有了一个设备——你能不能通过 Xcode 获得崩溃报告,并且 (1) 获得包含详细信息、故障类型等的堆栈跟踪,然后 (2) 将报告与你的应用程序来确定崩溃的确切位置?
-
这是我的问题的更新版本:stackoverflow.com/questions/25922180/… 我急忙尝试解决问题,最终将调试构建设置更改为与允许我重新创建的分发设置相同通过我的项目运行时崩溃。问题是我没有跟踪我所做的更改,所以事情变得非常混乱。
标签: swift uialertview