开发者

Forcing Touches to Multiple Views

开发者 https://www.devze.com 2023-03-12 02:04 出处:网络
I have two overlapping custom views that need to both receive touch events (e.g. touchesBegan and touchesMoved). However I can only get one of 开发者_C百科the Views (the top one) to receive the events

I have two overlapping custom views that need to both receive touch events (e.g. touchesBegan and touchesMoved). However I can only get one of 开发者_C百科the Views (the top one) to receive the events. I have tried forwarding the events from one view to the other view using:

[otherView touchesEnded:touches withEvent:event];

but this does not always work.

I need the touch events to be sent to the two views simultaneously. Can anyone help?


If you intercept a touch, you should usually call [super methodYouAreIntercepting] at the end of the method, if you still want the touch to go through to the next layer. If you do this, and the two views are directly on top of each other, then you don't need to manually forward the touches the way you have been doing. because your comment above suggests that you haven't been calling super in the method, I bet this will solve your issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号