简体   繁体   English

触摸事件视图和子视图

[英]touch events view and subview

I have a view and a subview. 我有一个视图和一个子视图。 I add the subview in the loadView method in my viewController. 我在viewController的loadView方法中添加子视图。 The first time a touch even occurs it goes to the view, and all subsequent touches go to the subview. 第一次甚至发生触摸时,它都会进入视图,而所有后续触摸都将进入子视图。 Why is it that this happens, and how would I be able to change it so that both the view and subview see all touch events? 为什么会发生这种情况,如何更改它以便视图和子视图都能看到所有触摸事件?

See the touchesBegan:withEvent: method reference discussion 请参阅touchesBegan:withEvent:方法参考讨论

To forward the message to the next responder, send the message to super (the superclass implementation); 要将消息转发给下一个响应者,请将消息发送到super(超类实现); do not send the message directly to the next responder. 不要将消息直接发送给下一个响应者。 For example, 例如,

[super touchesBegan:touches withEvent:event]; [super touchesBegan:toucheswithEvent:event];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM