Coder221 Coder221 - 1 year ago 96
iOS Question

Displaying action sheet when tableview cell is tapped

Then I am trying to call action sheet when cell is tapped, and this is what I did

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

let alertController = UIAlertController(title: "Action Sheet", message: "What do you like to do", preferredStyle: .alert)

let okButton = UIAlertAction(title: "Done", style: .default, handler: { (action) -> Void in
print("Ok button tapped")

let deleteButton = UIAlertAction(title: "Skip", style: .destructive, handler: { (action) -> Void in
print("Delete button tapped")


When i am tapping cell, alert controller is not showing up. What am I missing?

Answer Source

You're almost there, make sure you add your deleteButton-action as well and present the alertController using present(alertController, animated: true, completion: nil)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download