で 2 つのジェスチャ認識機能を使用していUIView
ます。1 つは standardUITapGestureRecognizer
で、もう 1 つは私が書いた非常に単純なタッチダウン レコグナイザーです。
@implementation TouchDownGestureRecognizer
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (self.state == UIGestureRecognizerStatePossible) {
self.state = UIGestureRecognizerStateRecognized;
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
self.state = UIGestureRecognizerStateFailed;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
self.state = UIGestureRecognizerStateFailed;
}
@end
このメソッドを含む両方にデリゲートを割り当てた場合にのみ、それらは連携して機能します。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
すべて正常に動作していますが、そのビューを長押しすると、タッチダウン認識エンジンが起動し、タッチアップ認識エンジンが起動しません。短いタップの場合はすべて問題なく、両方とも発火します。
すべてのメソッドを実装して、UIGestureRecognizerDelegate
YES を無駄に返しました。ロギングを追加して、デリゲートと自分のレコグナイザーの内部とのやり取りを確認すると、短いタップと長いタップの両方で、レコグナイザーの修正の呼び出しを除いて、呼び出しシーケンスが同じであることがわかります。私は何を間違っていますか?