1
votes

here is the panGesture's instance.

   pangstr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];

- (void)handlePan:(UIPanGestureRecognizer *)recognizer{

    CGPoint translation = [recognizer translationInView:baseView];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y);
    [recognizer setTranslation:CGPointMake(0, 0) inView:baseView];


    if (recognizer.state == UIGestureRecognizerStateEnded) {


        CGPoint velocity = [recognizer velocityInView:baseView];
        CGFloat magnitude = sqrtf((velocity.x * velocity.x));
        CGFloat slideMult = magnitude / 1000;
        NSLog(@"magnitude: %f, slideMult: %f", magnitude, slideMult);
        float slideFactor = 0.15 * slideMult;

        CGPoint finalPoint = CGPointMake(recognizer.view.center.x + (velocity.x * slideFactor),
                                         recognizer.view.center.y + (velocity.y * slideFactor));
}

Now my question is how can i use the (panGestureRecogniser *)recogniser parameter in - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event function. I want this specifically because i wanna get the finalPoint's value in my TouchesMoved function and CGPoint finalPoint uses the *recogniser parameter.

It would be really great if anyone could give me a solution Thanks

1

1 Answers

0
votes

Why not just used the recognisers state?

if (recognizer.state == UIGestureRecognizerStateChanged) 
{
    //Save whatever information you need here
}

With regard to shared variables, use a different one for StateChanged and sync them up in StateEnded?