3

私のアプリでは、ユーザーが上にパンしてコントロールを調整するオプションがありますが、パンが非常に速くなると少し遅くなり、もっとジャンプしたいと思います。

// If user is panning upwards or downwards, adjust WPM every 8 translations in either direction
if (translation.y<-8 || translation.y>8) {
    // Reset translation so we can see when it exceeds 8 again
    [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];

    // Figure out direction, if pan down, decrease by 5, if up, increase by 5
    int sign = (translation.y > 0) ? -1 : 1;
    WPM = @([WPM intValue] + (sign * 5));

    if ([WPM intValue] >= 200 && [WPM intValue] <= 1500) {
        self.WPMLabel.text = [WPM stringValue];

        self.wordsPerMinute = WPM;

        [[NSUserDefaults standardUserDefaults] setObject:WPM forKey:@"WPM"];
    }
}

より速い加速を考慮してこれを変更するにはどうすればよいですか?

4

2 に答える 2

2

ジェスチャ認識エンジンで速度プロパティを使用します。

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPanGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instm/UIPanGestureRecognizer/velocityInView :

于 2014-06-09T20:55:45.430 に答える