0

要素がスライドするようにビューをスライドさせたいUIScrollView。ユーザーはビューに触れて引っ張ることができ、加速度と位置に応じて、ビューが離れたり留まったりします。

UIPanGestureRecognizerと一緒に使用する必要がありUISwipeGestureRecognizerますか?

4

1 に答える 1

0

コンテンツをユーザーの指に追従させたい場合は、 UIPanGestureRecognizerを使用します (ここで行うように聞こえます)。スワイプジェスチャーは、スワイプが完了するのを待ってから、それについて教えてくれます。

'state' プロパティを使用して開始時と終了時の指の位置を取得し、速度を使用して加速度を決定します。

CGPoint location = [sender locationInView:self.view];

if(sender.state == UIGestureRecognizerStateBegan)
{
         startLocation = location;
}
  else if(sender.state == UIGestureRecognizerStateChanged)
{
      // Move view or do something to give feedback to user while they swipe
}
else if(sender.state == UIGestureRecognizerStateEnded)
{
    CGPoint distanceMoved = CGPointMake(location.x - startLocation.x, location.y - startLocation.y);
    CGPoint velocity = [sender velocityInView:self.view];
 // Logic goes here
}
于 2012-10-29T11:16:47.200 に答える