旋转滚轮iOS continueTrackingWithTouch时跳过数字

时间:2014-08-25 07:33:32

标签: ios rotation numbers drag

我创造了一个轮子,当我慢慢旋转时它工作正常。但是当它被更快地旋转/拖动时,数字会被跳过。以下是continueTrackingWithTouch方法:

- (BOOL)continueTrackingWithTouch:(UITouch*)touch withEvent:(UIEvent*)event
{

    CGPoint pt = [touch locationInView:self];

    float dx = pt.x  - container.center.x;
    float dy = pt.y  - container.center.y;
    float ang = atan2(dy,dx);

    float angleDifference = deltaAngle - ang;

    container.transform = CGAffineTransformRotate(startTransform, -angleDifference);

    [self.delegate wheelDidChangeValue:[self getCloveName:currentValue]];
    NSLog(@"%d", currentValue);

    CGFloat radians = atan2f(container.transform.b, container.transform.a);

    CGFloat newVal = 0.0;

    for (SMClove *c in cloves) {

        if (c.minValue > 0 && c.maxValue < 0) { // anomalous case

            if (c.maxValue > radians || c.minValue < radians) {

                if (radians > 0) { // we are in the positive quadrant

                    newVal = radians - M_PI;

                } else { // we are in the negative one

                    newVal = M_PI + radians;

                }
                currentValue = c.value;

            }

        }

        else if (radians > c.minValue && radians < c.maxValue) {

            newVal = radians - c.midValue;
            currentValue = c.value;

        }

    }

    //finding out the direction -> clockwise / anticlockwise
    if((currentValue > turnedValue) && (currentValue != 0 || currentValue != 99)){
        clockwise = false;
        turnedValue = currentValue;
    }else if((currentValue < turnedValue) && (currentValue != 0 || currentValue != 99)){
        clockwise = true;
        turnedValue = currentValue;
    }

    return YES;

}

以下是日志的外观:

2014-08-25 12:38:12.860 Cracker[2459:60b] 52
2014-08-25 12:38:12.877 Cracker[2459:60b] 49
2014-08-25 12:38:12.894 Cracker[2459:60b] 46
2014-08-25 12:38:12.910 Cracker[2459:60b] 43
2014-08-25 12:38:12.927 Cracker[2459:60b] 41
2014-08-25 12:38:12.945 Cracker[2459:60b] 40
2014-08-25 12:38:12.961 Cracker[2459:60b] 38
2014-08-25 12:38:12.977 Cracker[2459:60b] 37
2014-08-25 12:38:12.993 Cracker[2459:60b] 36
2014-08-25 12:38:13.011 Cracker[2459:60b] 35
2014-08-25 12:38:13.061 Cracker[2459:60b] 34
2014-08-25 12:38:13.085 Cracker[2459:60b] 32
2014-08-25 12:38:13.107 Cracker[2459:60b] 31

我已经记录了currentValue但是在旋转时没有记录一些数字。欢迎提出任何意见。

0 个答案:

没有答案