我有一个UIView子类,它有几个子视图,我想在类中处理这些事件:
但是我也希望在子视图中调用这些事件。我怎样才能做到呢?
(我已经尝试使用hitTest,但是我只获得TouchsBeging事件,并且没有使用该方法发送任何触摸)
我已通过在主窗口重写以下方法来解决此问题:
- (void)sendEvent:(UIEvent*)anEvent
我也会检查它是否是正确的事件通过
if ([[[anEvent allTouches] anyObject] phase] == UITouchPhaseBegan)
UITouchPhaseMoved UITouchPhaseEnded ,执行我的自定义代码,然后发送 [super sendEvent:anEvent];
UITouchPhaseMoved
UITouchPhaseEnded
[super sendEvent:anEvent];