Skip to content

Instantly share code, notes, and snippets.

@kazu69
Created July 6, 2014 10:24
Show Gist options
  • Save kazu69/9a06b90846b94b071be5 to your computer and use it in GitHub Desktop.
Save kazu69/9a06b90846b94b071be5 to your computer and use it in GitHub Desktop.
swift UIActionSheet sample
//
// 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));
}
}
@Hayllander
Copy link

obrigado

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment