hotTest中的touchesForView

时间:2010-01-13 14:52:16

标签: iphone uiview touch hittest touchesmoved

我有一个像容器一样使用的简单UIView。 如果我写这段代码:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    UIView *hitView = [super hitTest:point withEvent:event];

    NSSet *sTouches = [event touchesForView:self];

    NSLog(@"Touches %d", [sTouches count] );

    return self;
}

不起作用!在touchesBegan()之前,我想在hitTest()消息中获取触摸次数! 有可能吗?

我有这个层次结构:

UIView 
  +---> UIScrollView 

触摸我的UIView单击)时,容器会移动。当我在UIView上双击(双指)时,孩子UIScrollView不适用于缩放(例如)。 所以我想要抓住接触数量。

如果触摸号码等于1,hitTest容器上的UIView将返回“self”。 否则,如果触摸数量很大(== 2),hitTest返回“scrollview”指针。

换句话说,我想将两个手指事件捕获到hitTest()消息/事件中。

1 个答案:

答案 0 :(得分:1)

框架使用

hitTest来确定正在点击哪个视图,从而确定发送touchesBegan / touchesMoved / touchesEnded / {{1}的视图消息到。在调用touchesCancelled时,您无法分辨。

也许你可以解释一下你想要完成什么,因为这似乎不是正确的方法。