Last active
January 17, 2016 02:34
-
-
Save tdtsh/4abab4fcf5dc3e9d8b18 to your computer and use it in GitHub Desktop.
Swift2 で Alert を表示
This file contains 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
class MasterViewController: UITableViewController { | |
... | |
override func viewDidLoad() { | |
... | |
let cameraButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: "doCamera:") | |
... | |
} | |
... | |
func doCamera(sender: UIButton) { | |
// UIAlertControllerを作成する. | |
let sampleAlert: UIAlertController = UIAlertController(title: "アラートです", message: "カメラボタン押しました", preferredStyle: .Alert) | |
// アクションを作成、追加 | |
let yesAction = UIAlertAction(title: "OK", style: .Default) { action in print("OK!!") } | |
sampleAlert.addAction(yesAction) | |
// UIAlertを表示 | |
self.presentViewController(sampleAlert, animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment