Xcode UIAlert在IOS 7(Swift)中不起作用

Xcode UIAlert在IOS 7(Swift)中不起作用,xcode,swift,xcode5,Xcode,Swift,Xcode5,我在swift中有此警报确认框,它在IOS 8中工作正常,但在IOS 7中不工作,请问我如何解决它 这是我的密码 var refreshAlert = UIAlertController(title: "Cerrando la aplicacion!", message: "Seguro que desea Cerrar ?", preferredStyle: UIAlertControllerStyle.Alert) refreshAlert.addAction(UIAlertAc

我在swift中有此警报确认框,它在IOS 8中工作正常,但在IOS 7中不工作,请问我如何解决它

这是我的密码

 var refreshAlert = UIAlertController(title: "Cerrando la aplicacion!", message: "Seguro que desea Cerrar ?", preferredStyle: UIAlertControllerStyle.Alert)

    refreshAlert.addAction(UIAlertAction(title: "Si", style: .Default, handler: { (action: UIAlertAction!) in
        exit(0)
    }))
    refreshAlert.addAction(UIAlertAction(title: "No", style: .Default, handler: { (action: UIAlertAction!) in
        println("ho hace nada")
    }))
    presentViewController(refreshAlert, animated: true, completion: nil)
从:

iOS 8.0及更高版本提供了可用性

UIAlertController
对象向用户显示警报消息。这 类替换了的
UIActionSheet
UIAlertView
类 显示警报。将警报控制器配置为 所需的操作和样式,请使用
presentViewController:动画:完成:
方法

因此,对于iOS的早期版本,请使用
UIActionSheet
UIAlertView
(根据您的示例,
UIAlertView


此外,如果你想在AppStore中发布应用程序,则不能使用退出(0)退出应用程序,因为它不遵守苹果的指导原则。更多说明。

阅读UIAlertController的文档。特别是“可用性”部分。上面写着“在iOS 8.0及更高版本中可用”的地方,它的意思正是它所说的。什么是不工作<代码>UIAlertController在iOS8中引入。对于早期版本,如文档中所述,请使用
UIActionSheet
UIAlertView
。请注意,如果要在AppStore中发布,则无法执行“退出(0)”。我没有发现
退出(0)
。这在iOS应用程序中是一个很大的禁忌。事实上,它可能会让你的应用被拒绝。用户不应以这种方式退出应用程序。这就是主页按钮的作用。