は今、私はこれらの手順を使用して、この実装をした: -
あなたはクラス「UIGestureRecognizer」を拡張した後、いくつかのデリゲートメソッドを実装することができます。
ここにその方法があります。
//それはそれはそれはエンドスワイプポイント
ます// regural基づいて
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint point=[touches.anyObject locationInView:self.view];
}
をタッチポイントを与えるタッチ
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint startSwipePoint= [touches.anyObject locationInView:self.view];
}
//の出発点を与えます
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint endSwipePoint= [touches.anyObject locationInView:self.view];
}
//ここでは2点間の角度を計算するコードです。私は始点と終点を使用しています。しかし、あなたはあなたが座標に応じて、方向性を得ることができ、そこからパンジェスチャーの代わりに、あなたが開始することができますスワイプとエンドポイントを使用することができますあなたの条件に応じて
CGFloat angle=atan2(startSwipePoint.y -endSwipePoint.y,endSwipePoint.x - startSwipePoint.x) * Rad2Deg;
の2点のいずれかを使用することができます。または、最善の方法はViewにメソッドを使用することです。 –