UIAlert アクションシート

//
// ViewController.swift
// nonSample13
//
// Created by non on 2015/03/21.
// Copyright (c) 2015年 non. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func nonbtn(sender: UIButton) {
//アクションシート作成
var nonalertController = UIAlertController(
title:"タイトル",
message:"メッセージ",
preferredStyle:UIAlertControllerStyle.ActionSheet)
//アクションシート1追加
nonalertController.addAction(UIAlertAction(
title:"アクション1",
style:.Default,
handler:{action in self.myActionOne()}))
//アクションシート2追加
nonalertController.addAction(UIAlertAction(
title:"アクション2",
style:.Default,
handler:{action in self.myActionTwo()}))
//OKボタンを追加
nonalertController.addAction(UIAlertAction(
title:"OK",
style:.Default,
handler: { action in self.myOK() }
))
//削除ボタンを追加
nonalertController.addAction(UIAlertAction(
title:"削除",
style:.Destructive,
handler: { action in self.myDel()}
))
//Cancelボタンを追加
nonalertController.addAction(UIAlertAction(
title:"Cancel",
style:.Cancel,
handler: {action in self.myCancel() }
))
//アラート表示
presentViewController(nonalertController,animated:true, completion: nil)
}
func myActionOne(){
println("Action1")
}
func myActionTwo(){
println("Action2")
}
func myOK() {
println("OK")
}
func myDel(){
println("delete")
}
func myCancel(){
println("Cancel")
}
}









































