UIView通过某些事件
我有一个 UIView 位于另一个 UIView 之上,我希望顶部的 UIView 仅响应 1、2 和 3 次点击的 UITapGestureRecognizer,但任何其他事件都会传递到其下方的 UIView。下面的视图有一个 UIPinchGestureRecognizer 和一个 UIPanGestureRecognizer,但如果任何触摸位于顶部 UIView 上,则该视图将不起作用。如果我将顶部 UIView 设置为 userInteractionEnabled 为 NO,它就可以正常工作,但是我当然无法从顶部 UIView 获得点击。非常感谢任何提示。
I have a UIView on top of another UIView and I would like the top one to only respond to a UITapGestureRecognizer on 1, 2 and 3 taps, but any other event would be passed though to the UIView below it. The view below has a UIPinchGestureRecognizer and a UIPanGestureRecognizer, but won't work if any of the touches are on the top UIView. It works right if I set the top UIView to userInteractionEnabled to NO, but then I of course can't get the taps from the top UIView. Any tips are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 Touches 样本进行了调整。不确定这是否是正确的方法。
所有这些都是在视图控制器中通过两个视图(topView 和bottomView)完成的。
在 viewDidLoad 中,我将所有手势识别器添加到顶部视图 -
手势操作
我尚未完全测试所有代码。尝试一下,看看它是否有效。
I tweaked around with the Touches sample. Not sure if this is the right way to go about it.
All this is done in the View Controller with both views (topView and bottomView).
in the viewDidLoad I add all gesture recognizers to the top view -
The gesture actions
I have not fully TESTED all the code. Try it out and see it works.