Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018252
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:57:38+00:00 2026-05-20T09:57:38+00:00

Ok so I have been looking around at just about every option under the

  • 0

Ok so I have been looking around at just about every option under the sun for capturing multi-touch gestures, and I have finally come full circle and am back at the UIPanGestureRecognizer.

The functionality I want is really quite simple. I have setup a two finger pan gesture, and I want to be able to shuffle through some images depending on how many pixels I move. I have all that worked out okay, but I want to be able to capture if the pan gesture is REVERSED.

Is there a built in way that I’m just not seeing to detect going back on a gesture? Would I have to store my original starting point, then track the end point, then see where they move after that and se if its less than the initial ending point and then reverse accordingly? I can see that working, but I’m hoping there is a more elegant solution!!

Thanks

EDIT:

Here is the method that the recognizer is set to fire. Its a bit of a hack, but it works:

-(void) throttle:(UIGestureRecognizer *) recognize{

throttleCounter ++;

if(throttleCounter == 6){
    throttleCounter = 0;
    [self nextPic:nil];
}

UIPanGestureRecognizer *panGesture = (UIPanGestureRecognizer *) recognize;
UIView *view = recognize.view;
if(panGesture.state == UIGestureRecognizerStateBegan){
    CGPoint translation = [panGesture translationInView:view.superview];
    NSLog(@"X: %f, Y:%f", translation.x, translation.y);
}else if(panGesture.state == UIGestureRecognizerStateEnded){
    CGPoint translation = [panGesture translationInView:view.superview];
            NSLog(@"X: %f, Y:%f", translation.x, translation.y);
}
  }

I’ve just gotten to the point where I am going to start trying to track the differences between values…to try and tell which way they are panning

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:57:38+00:00Added an answer on May 20, 2026 at 9:57 am

    On UIPanGestureRecognizer you can use -velocityInView: to get the velocity of the fingers at the time that gesture was recognised.

    If you wanted to do one thing on a pan right and one thing on a pan left, for example, you could do something like:

    - (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer
    {
        CGPoint velocity = [gestureRecognizer velocityInView:yourView];
    
        if(velocity.x > 0)
        {
            NSLog(@"gesture went right");
        }
        else
        {
            NSLog(@"gesture went left");
        }
    }
    

    If you literally want to detect a reversal, as in you want to compare a new velocity to an old one and see if it is just in the opposite direction — whichever direction that may be — you could do:

    // assuming lastGestureVelocity is a class variable...
    
    - (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer
    {
        CGPoint velocity = [gestureRecognizer velocityInView:yourView];
    
        if(velocity.x*lastGestureVelocity.x + velocity.y*lastGestureVelocity.y > 0)
        {
            NSLog(@"gesture went in the same direction");
        }
        else
        {
            NSLog(@"gesture went in the opposite direction");
        }
    
        lastGestureVelocity = velocity;
    }
    

    The multiply and add thing may look a little odd. It’s actually a dot product, but rest assured it’ll be a positive number if the gestures are in the same direction, going down to 0 if they’re exactly at right angles and then becoming a negative number if they’re in the opposite direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around on the web and found some articles about the
I have been looking around for a visualization framework that would aid graph visualization
I have been looking around for solutions, and tried to implement what is often
I have been looking around ocn Google and Stackoverflow but haven't found what I
I have been looking around and even found a couple of related answers and
I have been looking around the web for this but cannot really find a
I have been looking around for awhile now and I can't seem to find
Hey i have been looking around and i cant find a way to get
Alright so I have been looking around (on SO and Google) to see if
So I am a little confused, I have been looking around trying to determine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.