Created
June 19, 2015 12:40
-
-
Save NoasProject/d4b82812c508685f51d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let alert:UIAlertController = UIAlertController(title:"Swiftアラートテスト2", | |
| message: "アラートのテストです。", | |
| preferredStyle: UIAlertControllerStyle.Alert) | |
| presentViewController(alert, animated: true, completion: nil) | |
| let cancelAction:UIAlertAction = UIAlertAction(title: "Cancel", | |
| style: UIAlertActionStyle.Cancel, | |
| handler:{ | |
| (action:UIAlertAction!) -> Void in | |
| /* | |
| キャンセルボタンを押された際の動作 | |
| */ | |
| println("キャンセルボタンで一番下に表示されます") | |
| }) | |
| let defaultAction:UIAlertAction = UIAlertAction(title: "通常ボタン", | |
| style: UIAlertActionStyle.Default, | |
| handler:{ | |
| (action:UIAlertAction!) -> Void in | |
| /* | |
| 通常ボタンが押された際のAction | |
| */ | |
| println("一般的なボタン") | |
| }) | |
| let destructiveAction:UIAlertAction = UIAlertAction(title: "削除ボタン", | |
| style: UIAlertActionStyle.Destructive, | |
| handler:{ | |
| (action:UIAlertAction!) -> Void in | |
| /* | |
| 削除ボタンが押された際のAction | |
| */ | |
| println("削除や変動的な処理の場合に利用します") | |
| }) | |
| alert.addAction(cancelAction) //キャンセルボタンの生成 | |
| alert.addAction(defaultAction) //デェフォルトの通常ボタンの生成 | |
| alert.addAction(destructiveAction) //削除など変異的なボタンの生成 | |
| self.navigationController?.pushViewController(alert, animated: true) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment