事件touchesForView:在超级视图中返回null
我有一个名为 BigView 的 UIView 子类,它重写了 TouchesMoved(除其他外),如下所示:
@implementation BigView
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet * viewTouches = [event touchesForView:self];
NSLog(@"set of touches: %@", viewTouches);
}
@end
我的 BigView 实例也有一个子视图(常规 UIView 实例) - 当我触摸该子视图内部时,上面的 touchesMoved
方法被调用,但 viewTouches
出现 null。子视图不会重写任何事件处理方法(touchesBegan
、touchesMoved
等)。我希望视图的触摸计数包含其子视图内的所有触摸,但它似乎并不是这样工作的。我在代码中做错了什么吗,或者这是它应该工作的方式,但我不明白为什么? (如果是后者,为什么这样更好?)
谢谢!
I have a subclass of UIView called BigView that overrides touchesMoved (among other things) like so:
@implementation BigView
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet * viewTouches = [event touchesForView:self];
NSLog(@"set of touches: %@", viewTouches);
}
@end
My BigView instance also has a subview (regular UIView instance) - when I touch inside that subview, the above touchesMoved
method gets called, but viewTouches
comes up null. The subView doesn't override any of the event handling methods (touchesBegan
, touchesMoved
, etc). I would expect the touch count for a view to include all of the touches inside its subviews, but it doesn't seem to be working that way. Am I doing something wrong in the code, or is this the way it should work and I don't understand why? (If the latter, why is this better?)
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论