0

SwipeGestureとTouchMovedで異なる操作をしたいのですが、スワイプすると両方とも呼び出されます。何か助けてください。

 Drecoginizer  = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFromD:)];
Drecoginizer.direction = UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:Drecoginizer];
4

1 に答える 1

0

私が理解したように、このスワイプが円の外側にある場合、セレクターがスワイプジェスチャに反応することは望ましくありません。この場合、スワイプセレクターの最初で、スワイプが円の上にあるかどうかを次のように確認する必要があります。

CGPoint lClick = [recognizer locationOfTouch:0 inView:self.view];

    //Distance from the center of the circle to the taped point
    int lDistance = sqrt(pow(lClick.x - lCircleCenter.x, 2) + pow(lClick.y - lCircleCenter.y, 2));

    if ((int)lDistance > (int)lCircleRadius) {
        return;
    }

それがあなたを助けることを願っています

于 2010-12-31T07:45:17.467 に答える