Created
July 6, 2014 10:24
-
-
Save kazu69/9a06b90846b94b071be5 to your computer and use it in GitHub Desktop.
swift UIActionSheet sample
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
// | |
// ViewController.swift | |
// | |
import UIKit | |
class ViewController: UIViewController, UIActionSheetDelegate { | |
@IBAction func tapButton(sender : AnyObject) { | |
var sheet: UIActionSheet = UIActionSheet(); | |
let title: String = "Please choose a course"; | |
sheet.title = title; | |
sheet.delegate = self; | |
sheet.addButtonWithTitle("Cancel"); | |
sheet.addButtonWithTitle("A course"); | |
sheet.addButtonWithTitle("B course"); | |
sheet.addButtonWithTitle("C course"); | |
sheet.cancelButtonIndex = 0; | |
sheet.showInView(self.view); | |
} | |
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. | |
} | |
func actionSheet(sheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int) { | |
println("index %d %@", buttonIndex, sheet.buttonTitleAtIndex(buttonIndex)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing!