2010-01-13 30 views
1

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

- (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,我的UIView容器上的hitTest返回“self”。 否则,如果触摸数字很大(== 2),hitTest返回“scrollview”指针。

换句话说,我想抓住两个手指事件到hitTest()消息/事件。

回答

1

hitTest用于由框架,以确定哪些视图被击中,从而哪个视图到touchesBegan/touchesMoved/touchesEnded/touchesCancelled消息发送到。在调用点hitTest时,您无法分辨。

也许你可以解释你想要完成的事情,因为这看起来并不是正确的做法。

+0

好吧,我有这个层次: 的UIView --->的UIScrollView 当我UIView(单一的水龙头)容器移动触摸。 当我双击我的UIView,子UIScrollView不适用于缩放(例如)。 所以我想抓住触动数字。如果触摸号码等于1,我的UIView容器上的hitTest返回“self”。 否则,如果触摸数字很大(== 2),hitTest返回“scrollview”。 – Undolog 2010-01-13 20:33:31