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

  • Home
  • SEARCH
  • 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 4321434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:44:44+00:00 2026-05-21T08:44:44+00:00

I am currently able to make an image scale by using the pinch gesture

  • 0

I am currently able to make an image scale by using the pinch gesture recognizer provided by Apple, but how can I limit the maximum scale for the image?

I have been using the SimpleGestureRecognizers sample from Apple, which sets the scale to 1, and makes it very easy to scale image, but when I remove it, it jumps suddenly, which is not nice. But then it is hard to track the scale since its alway set to 1.

Thank you in advance.

  • 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-21T08:44:45+00:00Added an answer on May 21, 2026 at 8:44 am

    UIKit will call your selector method many times for a single user gesture (pinch.) Each call will represent a small increment (or decrease) in the scale. If you handle each call to the method and scale your image correspondingly for each small increment, you will get a smooth animation.

    You use the recognizer’s scale property to modify your image. Then, you reset the property to 1.0 so that the next time the selector method is called, the scale property represents only the new small increment since the last one. You again re-scale your image by the new small increment and reset to 1.0. If you do not reset the recognizer’s scale and use it to re-scale your image, you will be scaling your image by the cumulative change, resulting in jumpy behavior (and incorrect scaling.)

    So, do make sure to be resetting the gesture recognizer’s scale to 1. To keep track of the total change in scale, you can create an instance variable, possibly also called ‘scale’, for your UIImageView or your ViewController. (In fact, if you used that new scale variable in drawRect to draw your image, you will only have to add a call to setNeedsDisplay in the setter. And you won’t have to write any code to redraw the image when the scale changes.)

    In any case, the following code (incorporating Ravin’s limit check, but on the new scale variable) should work for your selector method:

    - (void)pinch:(UIPinchGestureRecognizer *)recognizer
    {
        if (recognizer.state == UIGestureRecognizerStateChanged ||
            recognizer.state == UIGestureRecognizerStateEnded) {
            if (imageView.scale < yourScaleLimit) {
                imageView.scale *= recognizer.scale;
                //any other code to scale up the image if
                //just changing imageView.Scale is not enough
            }
            recognizer.scale = 1.0;
        }
    }
    

    I hope this is helpful.

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

Sidebar

Related Questions

Currently I am able to retrieve data from a MySQL db by using HTTP
Currently, I have: outByte.writeInt(0x49492a00); outByte.writeInt(0x08000000); But i want to be able to write all
How do I make the following script work? Currently I am able to create
I'm currently modifying an existing module from being able to upload one image to
In my current project (presentation, slide software) I need to be able to make
I am currently able to export my MySQL query to a tab delimited text
Currently, I'm finding a lib able to stream video from multiple sources through one
I am currently developing an application and I need to be able when pressing
I am currently writing a Employee store and I need to be able to
I currently have a form with inputs and name attributes. I'm able to get

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.