0
在我的應用程序中,我使用了SMRotatory輪進行旋轉。它作爲輪換正常工作。檢查iPhone中的旋轉SDk
但我想檢測到,旋轉是順時針還是逆時針?
//My code is as follow:
- (BOOL)continueTrackingWithTouch:(UITouch*)touch withEvent:(UIEvent*)event
{
CGFloat radians = atan2f(container.transform.b, container.transform.a);
// NSLog(@"rad is %f", radians);
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;
// NSLog(@"%f",angleDifference);
if (angleDifference>=0) {
//NSLog(@"positive");
[[NSUserDefaults standardUserDefaults]setValue:@"positive" forKey:@"CheckValue"];
}
else
{
// NSLog(@"negative");
[[NSUserDefaults standardUserDefaults]setValue:@"negative" forKey:@"CheckValue"];
}
container.transform = CGAffineTransformRotate(startTransform, -angleDifference);
bg.transform=CGAffineTransformRotate(startTransform, -angleDifference);
return YES;
}