2013-02-01 50 views
3

我需要在touchesMoved期间取消触摸事件,以便潜在的uiviews可以接收事件。请参阅下面的评论:touchesMoved期间取消触摸事件

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

    for (UITouch *touch in touches) 
    { 

     if (touch.view == self.touchOverlay) { 
      CGPoint touchLocation = [touch locationInView:touch.view]; 

      //perform checks on touch location and trip sensor if circumstances are met 

      if (self.touchSensorTripped) { 
       self.touchOverlay.userInteractionEnabled = NO; 
       //NEED TO CANCEL THE TOUCH HERE SO THAT VIEWS UNDERNEATH CAN RECEIVE THE TOUCH EVENTS 
      } 

     } 

    } 
} 

目前,底层视图直到触摸ENDS时才会收到触摸事件,这太迟了。我需要他们在叠加视图禁用时立即开始接收touchesMoved事件,而触摸仍在移动。我可以在评论的上面插入什么来执行此操作?

回答

0

我只是做了一些简单的测试应用程序的混乱,并发现调用 [[self superview]touchesMoved:touches withEvent:event];似乎适用于一个简单的视图层次结构,如果这就是你所拥有的。 superview的touchesMoved在视图touchesEnded之前绝对被调用。调用superviews touches以这种方式提前移动并没有导致它被再次调用

+0

感谢您的回应。事实上,我可以通过调用self.superview touchesMoved来获取touchesMoved以在父视图控制器中调用。但是,基础视图包含滚动视图,并且在手动调用touchesMoved时,这些滚动视图不会响应。我需要这些滚动视图才能正常工作。你能想到其他方式吗?我只希望上面的观点能够通过它下面的观点。 – soleil