iPhone - 检测触摸并取消它们?

时间:2011-08-01 02:51:50

标签: ios objective-c iphone uitouch touchescancelled

我正在讨论我的UIView。 在某些情况下我想要取消触摸,以便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?
}

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

2 个答案:

答案 0 :(得分:1)

TouchesEnded总是在您取消或未被取消的任何地方被调用,所以我建议改为:

   if (SOMETHING_SPECIAL)
   {

   }

在你的:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

答案 1 :(得分:0)

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

touchesCancelled:withEvent: