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()
これらのコードのいずれかを変更して完全に機能させるにはどうすればよいですか?