I created an action sheet, but the problem is that the delegate method is not called
myActionSheet = UIActionSheet()
myActionSheet.addButtonWithTitle(\"
Updated for Swift 3 :
If you want to show/open UIActionSheet on Button click, used below simple and updated code in yourViewController:
//Method Defination :
func showPaymentModeActionSheet() {
// 1
let optionMenu = UIAlertController(title: nil, message: "Choose Payment Mode", preferredStyle: .actionSheet)
// 2
let fullAction = UIAlertAction(title: "FULL", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.mPaymentModeTextField.text = "FULL"
})
let addvanceAction = UIAlertAction(title: "ADVANCE", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.mPaymentModeTextField.text = "ADVANCE"
})
//
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
(alert: UIAlertAction!) -> Void in
})
// 4
optionMenu.addAction(fullAction)
optionMenu.addAction(addvanceAction)
optionMenu.addAction(cancelAction)
// 5
self.present(optionMenu, animated: true, completion: nil)
}
//Method Call :
@IBAction func actionOnPaymentModeButton(_ sender: Any) {
// open action sheet
showPaymentModeActionSheet()
}