0

Refer to link UIAlertController - add custom views to actionsheet for my UI layout.

I have the same layout of custom action sheet in my app. The code is written in the same way. I noticed that in swift4 the "Cancel" button does not perform any action. When I tap on "Cancel" button in code below

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {(alert: UIAlertAction!) in 
     print("Cancel")
})

The code: print(Cancel") does not execute.

Dario
  • 6,152
  • 9
  • 39
  • 50
Santosh Kumar
  • 71
  • 1
  • 6

2 Answers2

0

I think you have a problem with a frame of the custom view.
Run you application on a simulator and press "Debug View Hierarchy":
enter image description here
After that you'll can exam frames of views.

Andrew Romanov
  • 4,774
  • 3
  • 25
  • 40
0

Try this handler

UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
            print("cancel")
        }))
Mixon McLaren
  • 257
  • 2
  • 6