-
Notifications
You must be signed in to change notification settings - Fork 472
Using UIActionSheet
Anthony Sherbondy edited this page May 12, 2015
·
2 revisions
Create and show the action sheet as below. The destructive title will appear in red.
var actionSheet = UIActionSheet(title: "Log Out", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: "Log Out")
actionSheet.showInView(view)
Set your view controller to be a UIActionSheetDelegate
class MyViewController: UIViewController, UIActionSheetDelegate {
...
}
Implement the UIActionSheet event method, as shown below.
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int)
// buttonIndex is 0 for Cancel
// buttonIndex ranges from 1-n for the other buttons.
}