UI アラートを実装しようとしているときに、いくつかの問題が発生しました。Xcode 8ベータ4でswift 3.0を使用しています。アラートをアクティブにするボタンを作成しようとしています.1つのボタン(キャンセル)はアラートを却下し、もう1つのボタン(OK)はUIActionボタンのようにアクションを実行しますが、できませんでした表示するアラートを取得することさえできます。
var warning = UIAlertController(title: "warning", message: "This will erase all content", preferredStyle: .Alert)
var okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
}
var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
UIAlertAction in
NSLog("Cancel Pressed")
}
warning.addAction(okAction) {
// this is where the actions to erase the content in the strings
}
warning.addAction(cancelAction)
self.presentViewController(warning, animated: true, completion: nil)