Ios/swift/AlertView
提供: 初心者エンジニアの簡易メモ
通知メッセージ
okのみ
let alert:UIAlertController = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) -> Void in print("ok") })) self.presentViewController(alert, animated: true, completion: {})
確認メッセージ
okとキャンセル
let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) -> Void in print("Cancel button tapped.") } let okAction = UIAlertAction(title: "OK", style: .Default) { (action) -> Void in print("OK button tapped.") } ac.addAction(cancelAction) ac.addAction(okAction) presentViewController(ac, animated: true, completion: nil)