Please help me that, how to smoothly rotate(fling) one circle image clock wise as well as anticlockwise,
I tried many thing but not getting the proper result.
so please help me for this, Thanks in advance.
(void)viewDidLoad { [super viewDidLoad]; ij = 0; rotatingDirection = 1; additionalOffset = 0; totalAnglesRotated = 0; isInFlingMode = TRUE; isOptionSelected = FALSE; viewAnimation.hidden = FALSE; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWhateverChange) name:@"DataDownload" object:nil];
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer setMaximumNumberOfTouches:1]; [panRecognizer setDelegate:self]; [imgViewdialer addGestureRecognizer:panRecognizer];
[self Imagesswipemethod];}
-(void)move:(id)sender {
            //[[[(UITapGestureRecognizer*)sender view] layer] removeAllAnimations];
    CGPoint convertedPoint = [self.view.superview convertPoint:self.view.frame.origin toView:nil];
        // NSLog(@" Convert Point.. :: x = %f , y = %f",convertedPoint.x,convertedPoint.y);
            [imgViewdialer bringSubviewToFront:[(UIPanGestureRecognizer*)sender view]];         CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:view1.superview];   //  NSLog(@" trans values.. :: x
= %f , y = %f",translatedPoint.x,translatedPoint.y);
    int y=translatedPoint.y;
    int xx = translatedPoint.x;
        if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
                        firstX = [[sender view] center].x;          firstY = [[sender view] center].y;      }
                translatedPoint = CGPointMake(firstX+translatedPoint.x, firstY+translatedPoint.y);
                if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) {
                        if (isInFlingMode) {
                //NSLog(@"Completed");
                CGPoint vPoint = [panRecognizer velocityInView:imgViewdialer.superview];
                double point = [panRecognizer locationInView:view1].x;
                double pinty = [panRecognizer locationInView:view1].y;
                NSLog(@"touch Point y %f",pinty);
                NSLog(@"touch Point x %f",point);
                NSLog(@"Translate Point x %d",xx);
                NSLog(@"Translate Point y %d",y);
                float angleToBeRotated = (vPoint.x + vPoint.y) ;
                //(vPoint.x < 0) && (vPoint.y >= 0)) || ((vPoint.x < 0) && (vPoint.y < 0)
                if(point>160)
                {
                    if(y<0)
                        rotatingDirection = -1;
                    else if(y>0)
                        rotatingDirection = 1;
                } else {
                    if(y<0)
                        rotatingDirection = 1;
                    else if(y>0)
                        rotatingDirection = -1;
                }
                if(pinty > 200 && xx <0)
                    rotatingDirection = 1;
                else if(pinty >200 && xx>160)
                    rotatingDirection = -1;
                            //  rotatingDirection = 1;
                angleToBeRotated = (angleToBeRotated > 0) ? angleToBeRotated : (angleToBeRotated * -1);
                globalAngle = angleToBeRotated;
                ////NSLog(@"angleToBeRotated = %f", (globalAngle / 75.0));
                [NSThread detachNewThreadSelector:@selector(rotaterThreadMethod) toTarget:self withObject:nil];
                        }       } else {
                /*  CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender locationInView:view1];           ////NSLog(@"Current Point X = %f, Y = %f", translatedPoint.x + firstX, translatedPoint.y + firstY);             previousTouchPoint = CGPointMake(firstX, firstY);
                        if(!isOptionSelected) {
                CGPoint center = CGPointMake(CGRectGetMidX([imgViewdialer bounds]), CGRectGetMidY([imgViewdialer bounds]));
                ////NSLog(@"Center Point X = %f, Y = %f", center.x, center.y);
                CGPoint currentTouchPoint = CGPointMake(translatedPoint.x , translatedPoint.y);
                CGFloat angleInRadians;
                if((previousTouchPoint.x != 0) && (previousTouchPoint.y != 0)) {
                    angleInRadians = atan2f(currentTouchPoint.y - center.y, currentTouchPoint.x - center.x) - atan2f(previousTouchPoint.y - center.y, previousTouchPoint.x - center.x);
                }
                //previousTouchPoint = currentTouchPoint;
                CGFloat angleInDegree = RadianTodegrees(angleInRadians);
                angleInDegree = globalAngle+angleInDegree;
                [self rotateAccordingToAngle:degreesToRadian(angleInDegree)];
                revolutions+= (angleInDegree/360.0f);           }*/
                    }    }
- (void)rotateAccordingToAngle:(float) angle
{
    ////NSLog(@"Current Global Angle = %f", globalAngle);
    totalAnglesRotated += RadianTodegrees(angle);
    if(totalAnglesRotated >= 360)
        totalAnglesRotated -= 360;
    else if(totalAnglesRotated <= -360)
        totalAnglesRotated += 360;
    lblRotatingAngle.text = [[NSNumber numberWithFloat:totalAnglesRotated] stringValue];
    [imgViewdialer setTransform:CGAffineTransformRotate(imgViewdialer.transform, angle)];
}