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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:25:31+00:00 2026-06-04T09:25:31+00:00

I have an iPad application that has a base image UIImageView (in this case

  • 0

I have an iPad application that has a base image UIImageView (in this case a large building or site plan or diagram) and then multiple ‘pins’ can be added on top of the plan (visually similar to Google Maps). These pins are also UIImageViews and are added to the main view on tap gestures. The base image is also added to the main view on viewDidLoad.

I have the base image working with the pinch gesture for zooming but obviously when you zoom the base image all the pins stay in the same x and y coordinates of the main view and loose there relative positioning on the base image (whose x,y and width,height coordinates have changed).

So far i have this…

- (IBAction)planZoom:(UIPinchGestureRecognizer *) recognizer;
{
    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
    recognizer.scale = 1;

    for (ZonePin *pin in planContainer.subviews) {
        if ([pin isKindOfClass:[ZonePin class]]){
            CGRect pinFrame = pin.frame;

            // ****************************************
            // code to reposition the pins goes here...
            // ****************************************

            pin.frame = pinFrame;
        }
    }
}

I need help to calculate the math to reposition the pins x/y coordinates to retain there relative position on the zoomed in or out plan/diagram. The pins obviously do not want to be scaled/zoomed at all in terms of their width or height – they just need new x and y coordinates that are relative to there initial positions on the plan.

I have tried to work out the math myself but have struggled to work it through and unfortunately am not yet acquainted with the SDK enough to know if there is provision available built in to help or not.

Help with this math related problem would be really appreciated! 🙂

Many thanks,
Michael.
InNeedOfMathTuition.com

  • 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-04T09:25:34+00:00Added an answer on June 4, 2026 at 9:25 am

    First, you might try embedding your UIImageView in a UIScrollView so zooming is largely accomplished for you. You can then set the max and min scale easily, and you can scroll around the zoomed image as desired (especially if your pins are subviews of the UIImageView or something else inside the UIScrollView).

    As for scaling the locations of the pins, I think it would work to store the original x and y coordinates of each pin (i.e. when the view first loads, when they are first positioned, at scale 1.0). Then when the view is zoomed, set x = (originalX * zoomScale) and y = (originalY * zoomScale).

    I had the same problem in an iOS app a couple of years ago, and if I recall correctly, that’s how I accomplished it.

    EDIT: Below is more detail about how I accomplished this (I’m looking my old code now).

    I had a UIScrollView as a subview of my main view, and my UIImageView as a subview of that. My buttons were added to the scroll view, and I kept their original locations (at zoom 1.0) stored for reference.

    In -(void)scrollViewDidScroll:(UIScrollView *)scrollView method:

    for (id element in myButtons)
    {
       UIButton *theButton = (UIButton *)element;
       CGPoint originalPoint = //get original location however you want
       [theButton setFrame:CGRectMake(
           (originalPoint.x - theButton.frame.size.width / 2) * scrollView.zoomScale,
           (originalPoint.y - theButton.frame.size.height / 2) * scrollView.zoomScale,
           theButton.frame.size.width, theButton.frame.size.height)];
    }
    

    For the -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView method, I returned my UIImageView. My buttons scaled in size, but I didn’t include that in the code above. If you’re finding that the pins are scaling in size automatically, you might have to store their original sizes as well as original coordinates and use that in the setFrame call.

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

Sidebar

Related Questions

I'm making an application for the iPad. I have a view controll that has
I have an iPhone application in the store that has in-app purchases. This app
I have this iPad application with different NIBs and views. Each view has two
I have an application on the store that has two versions: for iPad and
We're building a web-based application that requires heavy image processing. We'd like this processing
I have ipad application which has 3 tableviews with holds data like label,image,property lists
I have an iPad application that pulls in all of its data from an
Has Anyone tried using PDF in iPad Application, using CGPDf functions. I have used
I have an iPad app that has a UITableViewController that implements the NSFetchedResultsControllerDelegate .
I have an iPad application that uses the whole screen (that is, UIStatusBarHidden is

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.