Numbers are skipped when spinning wheel iOS continueTrackingWithTouch
I created a wheel and it works great when I spin slowly. But when it rotates / drags faster the numbers are skipped. Below is the continueTrackingWithTouch method:
- (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;
}
Below is what the log looks like:
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
I registered currentValue, but some numbers are not registering when rotating. Any comments are appreciated.
+3
source to share
No one has answered this question yet
Check out similar questions: