简体   繁体   English

在自定义操作表中无法点击“取消”按钮

[英]Cancel Button is not tappable in custom action sheet

Refer to link UIAlertController - add custom views to actionsheet for my UI layout. 请参阅链接UIAlertController-为我的UI布局向操作表添加自定义视图

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. 我注意到在swift4中,“取消”按钮不会执行任何操作。 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. 代码: print(Cancel")不执行。

I think you have a problem with a frame of the custom view. 我认为您的自定义视图框架存在问题。
Run you application on a simulator and press "Debug View Hierarchy": 在模拟器上运行应用程序,然后按“ Debug View Hierarchy”:
在此处输入图片说明
After that you'll can exam frames of views. 之后,您可以检查视图框架。

Try this handler 试试这个处理程序

UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
            print("cancel")
        }))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM