如何传递让子视图UIButton获取按下事件?
我有一个带有点击手势的视图,其上有一个 UIButton 及其相应的操作。 问题是,如果我按下按钮,则不会调用其相应的操作,而是会调用点击处理程序。
我做了一个点击测试,并在点击按钮时停止手势处理程序执行任何操作。
但我无法让按钮的操作执行某些操作。
I have a view with a tap gesture and a UIButton on it with its corresponding action.
The problem is that If I press the button its corresponding action is not getting called instead the tap handler is getting called.
I did a hitTest and stopped the gesture-handler from doing anything if the hit was on the button.
But I am unable to let the button's action do something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将控制器类设置为 UIGestureRecognizer 的委托,然后实现此方法:
您的 hitTest 方法实际上应该实现此目的,因此您还可以检查 UIButton 是否确实正在获取分配给它的操作。
You can set your controller class to be the delegate of the UIGestureRecognizer and then implement this method:
Your hitTest method should actually achieve this, so you might also check if the UIButton is really getting an action assigned to it.