我知道我必須設置代表(我是這樣做的:class ShiftOverview: UITableViewController, UIActionSheetDelegate {...
),但是當我點擊按鈕時,我仍然沒有得到任何迴應。如何創建UIActionSheet操作?
它看起來並不像您可以設置功能中的委託與UIAlertController
要麼...
@IBAction func takeShift(sender: AnyObject) {
let myActionSheet = UIAlertController (title: "Confirm", message: "Test message", preferredStyle: UIAlertControllerStyle.ActionSheet)
let actionOne = UIAlertAction (title: "Take Shift", style: .Default, handler: nil)
let actionTwo = UIAlertAction (title: "View ESA", style: .Default, handler: nil)
let actionCancel = UIAlertAction (title: "Cancel", style: .Cancel, handler: nil)
myActionSheet.addAction(actionOne)
myActionSheet.addAction(actionTwo)
myActionSheet.addAction(actionCancel)
self.presentViewController(myActionSheet, animated: true, completion: nil)
}
func actionSheet (myActionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int)
{
switch buttonIndex {
case 0:
println ("test0")
break
case 1:
println ("test1")
break
case 2:
println ("test2")
break
default:
println("nope")
}
}
感謝您的幫助:) – dom999999