0

我正在处理Touches代表和UITapGestureRecognizer单击。以下是方法。当我单击我的视图时,我得到三个事件,顺序为TouchesBeganSingleTapTouchesEndedTouchesEnded当我检测到时,是否有停止事件SingleTap?基本上我不想在没有发生的情况下执行TouchesEnded任务TouchesMoved。我已经使用 failTouchEnded BOOL 变量完成了这项工作,SingleTap并在 TouchesEnded 中对其进行了检查,但不确定这是否是个好主意!

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

    }

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
          failTouchEnded = NO;
    }

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
          if(failTouchEnded) return;

    }

    - (void)GestureView:(GestureView*)view handleSignleTap:(UITapGestureRecognizer*)recognizer {
          failTouchEnded = YES;
    }
4

1 回答 1

0

手势识别器有一个属性 cancelsTouchesInView。如果是 YES(这是默认值),如果手势识别器识别出手势,则取消触摸。因此,您将取消触摸而不是结束触摸。如果不是 YES,您也应该将 delaysTouchesEnded 设置为 YES

于 2013-01-07T17:15:08.670 回答