0
私は4つのジェスチャーを作成し、次のコードを持っている:UILongPressGestureRecognizerとUISwipeGestureRecognizerを併用することはできますか?
self.userInteractionEnabled = YES;
UIPanGestureRecognizer * panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[panGesture setDelegate:self];
[self addGestureRecognizer:panGesture];
UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongPress:)];
longPressGesture.minimumPressDuration = 0.00;
[self addGestureRecognizer:longPressGesture];
UISwipeGestureRecognizer * swipeUp = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeUp:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipeUp];
UISwipeGestureRecognizer * swipeDown = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeDown:)];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[self addGestureRecognizer:swipeDown];
パンとLongPressは正常に動作しますが、私はスワイプジェスチャーのいずれかを取得することはありません。スワイプセレクタを呼び出すために何か特別なことがありますか?
おかげ
LOL、そうでした。私はその文書を読んだが、私は確認を見つけることができなかったが、問題を見る。上のコードに気付いた場合、私はLongTap minimumPressDurationを0.00に設定します。私がこれを行い、両方のジェスチャー(パンとスワイプ)でブレークポイントを設定すると、パンだけが壊れます。しかし、minimumPressDurationを0.125、1/4秒に送信した場合、それは両方で壊れます。私はこれを説明した何も見つけることができませんでしたので、pressDurationがなぜ重要であるかについて、私は躊躇しています。しかし、はい、あなたのソリューションはほとんどの場合、機能します。 – LilMoke