是否可以单击按钮并让点击向下滴到按钮的父 View ?我尝试禁用按钮并检测到点击,但是是否可以单击按钮,执行某些操作,然后让点击事件慢慢下降?
UIViewControllerWrapperView包含UIView包含UIView包含UIButton
当我点击/按下按钮时应该像这样,
点击按钮 > UIView 被点击 > UIView 被点击 > UIViewControllerWrapperView 检测点击
编辑: 我可以检测 UIViewControllerWrapperView 上的点击,但是,如果我单击按钮,则不会检测到点击,因为我假设点击事件由按钮处理,而按钮又会阻止下面的 View 检测到点击。
最佳答案
isUserInteractionEnabled 属性
尝试设置 UIButton 的 isUserInteractionEnabled
属性设置为false
。 UIButton 的默认值为 true
。
请注意,isUserInteractionEnabled
是在 UIButton 继承的 UIView 类上声明的。
在代码中设置isUserInteractionEnabled
button.isUserInteractionEnabled = false
在 Interface Builder 中设置 isUserInteractionEnabled
在 UIButton 的属性检查器中:
关于 swift : Button click stops tapGestureDidRecognize on the parent View,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41213678/