我编写了代码,在单击按钮时显示一个简单的警报弹出窗口。在模拟器 iPhone 4s (8.1) 中尝试该应用程序时,它按预期工作,但在模拟器 iPhone 4s (7.1) 中尝试时,该应用程序不断崩溃。
代码如下:
@IBAction func buttonPressed(sender: UIButton) {
let controller = UIAlertController(title: "This is a title", message: "Hello, my friend", preferredStyle: UIAlertControllerStyle.Alert)
let cancelAction = UIAlertAction(title: "Phew!", style: .Cancel, handler: nil)
controller.addAction(cancelAction)
self.presentViewController(controller, animated: true, completion: nil)
}
这是错误信息:
第一行代码(创建“ Controller ”常量的代码)以绿色突出显示,并显示消息“Thread 1: EXC_BAD_ACCESS(Code=1,address=0x10)”
如果有任何帮助,我将不胜感激
最佳答案
UIAlertController 适用于 iOS >= 8.0
您必须使用适用于 iOS <8.0 的 UIAlertView
关于ios - Swift Alert 弹出窗口出现在模拟器 iphone 4s(8.1) 中,而不是 iphone 4s (7.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28834395/