ユーザーが左から右にスライドすると、ラベルカウンターが1から5に更新されます。ゆっくり、非常にゆっくりとスワイプすると、それより速く動作し、正しく動作しませんか? これを実装する別の方法はありますか?
私はこのコードを持っています:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
if ((int)(currentPosition.x)%40 == 0 && counter < 5) {
counter++;
}
[label setText:[NSString stringWithFormat:@"%d", counter]];
}