0

我正在检测我的 UIView。在某些情况下,我想取消触摸,这样 touchesEnded 就不会被调用。但是不管 touchesEnded 总是会被调用吗?

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
   if (SOMETHING_SPECIAL)
   {
      [super touchesCancelled:touches withEvent:event];
   }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
   //I don't want it to get here if touches were canceled how can i do this?
}

- 在我的 touchesEnded 中,我如何确定触摸是否被取消?

4

2 回答 2

1

TouchesEnded无论您是否取消触摸,总会调用,所以我建议改为使用那个确切的:

   if (SOMETHING_SPECIAL)
   {

   }

在你的:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
于 2011-08-01T02:54:32.103 回答
0

要获取 touchesCancelled 事件,请从 UIResponder 实现此方法。

touchesCancelled:withEvent:

于 2011-08-01T05:11:31.127 回答