3

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

-(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
            }

        }

    }
}

目前底层视图在触摸结束之前不会接收触摸事件,这为时已晚。一旦覆盖视图被禁用,我需要他们立即开始接收 touchesMoved 事件,而触摸仍在移动。我可以在上面的评论中插入什么来做到这一点?

4

1 回答 1

0

I just did some simple messing around with a test app, and found that calling [[self superview]touchesMoved:touches withEvent:event]; seemed to work for a straightforward view hierarchy, if that's what you have. The superview's touchesMoved was definitely called before the view touchesEnded. Calling the superviews touchesMoved prematurely in this way didn't cause it to be called again afterwards

于 2013-02-02T20:38:20.140 回答