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 8371791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:14:49+00:00 2026-06-09T14:14:49+00:00

I am trying to add gesture recognizers to a view. When I add both

  • 0

I am trying to add gesture recognizers to a view. When I add both pan (for move) and pinch (for scale), I get some strange behavior.

After the view (which happens to contain an imageView) is scaled the pan gesture recognizer seems to multiply the effect of the move. Or it still assumes the original scale so the move is faster than it should be?

Here is the code for the methods to move and scale:

//ivars for gesture recognizers/transforms
CGFloat scale;
CGFloat rotation;
CGPoint translatedPoint;
CGFloat _lastScale;
CGFloat _lastRotation;  
CGFloat _firstX;
CGFloat _firstY;

-(void)scale:(id)sender {
    if([(UIPinchGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
        _lastScale = 1.0;
    }
    scale = 1.0 - (_lastScale - [(UIPinchGestureRecognizer*)sender scale]);
    CGAffineTransform currentTransform = gestureView.transform;
    CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, scale, scale);
    [gestureView setTransform:newTransform];
    _lastScale = [(UIPinchGestureRecognizer*)sender scale];
    NSLog(@"gestureView origin x: %f, y: %f", gestureView.frame.origin.x, gestureView.frame.origin.y);
    NSLog(@"gestureView center x: %f, y: %f",[gestureView center].x, [gestureView center].y);
    NSLog(@"gestureView scale x: %f, scale y: %f", gestureView.frame.size.width, gestureView.frame.size.height);

}

-(void)move:(id)sender {
    translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:gestureView];
    if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
        _firstX = [gestureView center].x;
        _firstY = [gestureView center].y;
    }
    translatedPoint = CGPointMake(_firstX+translatedPoint.x, _firstY+translatedPoint.y);
    [gestureView setCenter:translatedPoint];
    NSLog(@"gestureView origin x: %f, y: %f", gestureView.frame.origin.x, gestureView.frame.origin.y);
    NSLog(@"gestureView center x: %f, y: %f",[gestureView center].x, [gestureView center].y);
}

Here is the project:
owolf.net/uploads/StackOverflow/GestureRecognizerTest.zip

Thanks for reading!

  • 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-06-09T14:14:50+00:00Added an answer on June 9, 2026 at 2:14 pm

    You’re asking for translation inside the gestureView, which will give you the scaled translation. If the gestureView was scaled down to 50%, a 10 pixel move along x-axis would give x=20 in the translatedPoint value, because 10 pixels “on the outside” doubles on the scaled down (“higher resolution”) gestureView.

    You then apply that to the gestureView’s frame (center is simply a convenience method which sets the frame to center.x - frame.size.width/2, center.y - frame.size.height/2, frame.size) which means it’s affected by the scale.

    What you probably want to do is change the translationInView: call to look in gestureView.superview, not in gestureView itself.

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

Sidebar

Related Questions

Im trying to follow this article for having simultaneous pan and pinch gesture recognizers
Hi, I am trying to add gesture recognizers to 'UIButton'. When I do it
Trying to add some different filters (in addition to the ForeignKey filter) to a
I just trying to get to QLPreviewController.view. Indeed, I want to catch a tap
i know how to add a gesture recognizer via the IB but I'm trying
Trying to add some extra elements to my session variables for filesystem directory work,
im trying add item with ajax, all work, except the view doesnt refresh, when
was trying to add this gesture function to my first program, and almost every
Trying to add some html to a TextArea in Mobile Flex 4.5 but keep
I'm trying add some implicit rules in CMake that will generate direct dependencies (like

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.