2013-01-15 29 views
0

在我的视图层次结构的底部,我实现了touchesBegan方法。它触发所有触摸,除了单手指轻拍。这让我相信,在层次结构中更高的地方,一种观点是拦截/处理单指轻拍,但我无法找到我生活的观点。有没有一种很好的方法来调试呢?如何检测哪个视图正在处理我的水龙头?

+0

你认为则hitTest:withEvent:方法会有所帮助?看看这个线程http://stackoverflow.com/questions/4961386/event-handling-for-ios-how-hittestwithevent-and-pointinsidewithevent-are-r。 – sridevi

+0

不幸的是'hitTest:withEvent:'返回没有接收到水龙头的视图。它似乎不受手势识别器的影响。 –

回答

0

试试这个方法,如果它的工作了:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *touch = [[event allTouches] anyObject]; 
    CGPoint touchLocation = [touch locationInView:self.contentView]; 

    for (UIView *view in self.contentView.subviews) 
    { 
     if ([view isKindOfClass:[MyCustomView class]] && 
      CGRectContainsPoint(view.frame, touchLocation)) 
     { 

     } 
    } 
} 
+0

不幸的是,'touchesMoved'不会被调用。单指轻敲不会触及任何触摸方法。它们都适用于多指水龙头或平底锅或除单指水龙头以外的任何其他触感。 –

相关问题