如何在 Swift 中添加消息框并使其与 IOS 7 + 兼容
我有以下适用于 IOS 8 的代码:
var alert = UIAlertController(title: "hello world", message:
"DO YOU WANT TO PLAY", preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: false, completion: nil)
alert.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.Default,
handler: nil))
alert.addAction(UIAlertAction(title: "Yes", style: .Default, handler:
{action in
// CODE
}))
我有以下适用于 IOS 7 + 的代码(我不知道如何响应按钮单击):
var alert = UIAlertView()
alert.title = "HelloWorld"
alert.message = "DO YOU WANT TO PLAY"
alert.addButtonWithTitle("Yes")
alert.addButtonWithTitle("No")
alert.show()
如何修改这些代码中的任何一个并使其充分发挥作用?