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 に答える