iphone - 触摸(点击)事件的顺序
我有一个 UIView 和一个 UIWebView。
UIWebView 是 UIView 的子视图。
UIWebView 包含 YouTube 视频,并设置为让视频适合 UIWebView。
我有一个与父 UIView 关联的用于单击的 UITapGesture,比如说,如果用户单击整个视图,它将调用 A。
因此,当 UIWebView 加载 youtube 视频时,视频顶部有一个按钮等待用户点击播放。但现在如果我单击该按钮,则会播放 youtube,同时也会调用 A。这就是我不想要的。
我该怎么解决呢?
我认为触摸/点击事件应该按顺序排列,如果单击按钮,它应该吸收该事件并且不再给 UIView 提供任何信息。
我还尝试在 UIWebView 下添加另一个 UIView,并将该手势附加到底层视图。然而,它仍然不起作用。
我怎样才能让youtube视频上的按钮独立?
谢谢
I have a UIView and a UIWebView.
The UIWebView is a child view of the UIView.
The UIWebView contains a youtube video and is set as to let the video fit to the UIWebView.
I have a UITapGesture associated with the parent UIView for single tap, say, if a user single tap the whole view, it will invoke A.
So, when the UIWebView loads the youtube video, there is a button on top of the video waiting for users to click to play. But now if I click the button, the youtube is played, but also the A is invoked too. This is what I don't want.
How should I solve it?
I thought the touch/tap event should be in a order and if the button is clicked, it should absorb the event and not give the UIView any more.
I also tried to add another UIView under the UIWebView, and attach that gesture to the underlying view. However, it still doesn't work.
How can I do to let the button over the youtube video independent?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在视图的 .m 文件中添加此代码(如果您使用的是 UIView,请将其子类化):
由于我没有尝试此代码,请告诉我它是否不起作用。处理这种情况的方法仍然有很多。 :)
Try add this code in your view's .m file (if you are using UIView, subclass it):
Since I did not try this code, tell me if it doesn't work. There are still many ways to deal with the situation. :)