「Ios/swift/AlertView」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==エラーメッセージ== let alert = UIAlertView(title: "エラー", message: "エラーです", delegate: self, cancelButtonTitle: "OK") alert.show()」) |
|||
行2: | 行2: | ||
let alert = UIAlertView(title: "エラー", message: "エラーです", delegate: self, cancelButtonTitle: "OK") | let alert = UIAlertView(title: "エラー", message: "エラーです", delegate: self, cancelButtonTitle: "OK") | ||
alert.show() | alert.show() | ||
+ | |||
+ | ==確認メッセージ== | ||
+ | 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) | ||
+ | 参考:http://qiita.com/osamu1203/items/f1aea7b932e69522f638 |
2016年7月29日 (金) 21:55時点における版
エラーメッセージ
let alert = UIAlertView(title: "エラー", message: "エラーです", delegate: self, cancelButtonTitle: "OK") alert.show()
確認メッセージ
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)