Skip to content

Instantly share code, notes, and snippets.

@dereksee
Forked from kazu69/ViewController.swift
Last active August 29, 2015 14:24
Show Gist options
  • Save dereksee/ee012cc65c9f8f8eb245 to your computer and use it in GitHub Desktop.
Save dereksee/ee012cc65c9f8f8eb245 to your computer and use it in GitHub Desktop.
//
// 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