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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:16:45+00:00 2026-06-06T11:16:45+00:00

I’m a beginner to the iOS development, and I’m trying to display an image

  • 0

I’m a beginner to the iOS development, and I’m trying to display an image (a map in fact) which need to be zoomable and pannable. My problem is that I don’t know how to add an overlay which will follow the pan to always represent the same location, but won’t be scaled by the zoom. There will be several overlays, and each one must be clickable.

To zoom and pan the image (map), I added my UIImageView in a UIScrollView and it works great, but I have no idea how to add this feature.

I found this thread but it is not really the same problem since his overlay is static :
UIScrollview with two images – Keeping 1 image zoomable and 1 image static (fixed size)

I’ve developped the same application in android, and to make this work I was converting a pixel of the map in screen coordinates thanks to the transformation matrix, and I overrode the onDraw method to display it, but I don’t know how to do the same on iOS, and I don’t know if this is the better solution.

Thanks for any help.

  • 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-06T11:16:48+00:00Added an answer on June 6, 2026 at 11:16 am

    Ok so I found a way to do it, if it can helps anybody :

    I added my overlay in the scrollView, with the background image (the map).

    +CustomScrollView
    ----> UIImageView (map)
    ----> OverlayImageView (overlay)
    

    In order to zoom, the custom scrollview need a delegate with the following methods :

    - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
        //The background image with the map
        return mapView;
    }
    
    //When a zoom occurs, move the overlay
    - (void)scrollViewDidZoom:(UIScrollView *)scrollView {
        UIImageView* overlayView = [scroll.subviews objectAtIndex:1];
        float x;
        float y;
        float width;
        float height;
    
        //keep the width and height of the overlay
        width = overlayView.frame.size.width;
        height = overlayView.frame.size.height;
        //Move it to stay over the same pixel of the map, and centers it
        x = (self.overlay.point.x * scroll.zoomScale - width/2);
        y = (self.overlay.point.y * scroll.zoomScale - height/2);
    
        overlayView.frame = CGRectMake(x,y,width,height);
    } 
    

    With this, we are saying that the zoom only occurs on the background image, but as the overlay is in the UIScrollView, it pans with it. So the only thing we need to care is to move the Overlay when the zoom change, and we know it with the scrollViewDidZoom method.

    To handle the touch events, we override the touchEnded:withEvent: of CustomScrollView and we forward it to the overlay if there is only one tap. I don’t show the OverlayImageView since it only override this same method (toucheEnded:withEvent:) to handle a touch on it.

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch* touch = [touches anyObject];
        // Coordinates in map view
        CGPoint point = [touch locationInView:[self.subviews objectAtIndex:0]];
    
        //forward
        if(touch.tapCount == 1){
            OverlayImageView* overlayView = [self.subviews objectAtIndex:1];
            CGPoint newPoint = [touch locationInView:overlayView];
    
            BOOL isInside = [overlayView pointInside:newPoint withEvent:event];
    
            if(isInside){
                [overlayView touchesEnded:touches withEvent:event];
            }
        }
        // zoom
        else if(touch.tapCount == 2){
    
    
            if(self.zoomScale == self.maximumZoomScale){
                [self setZoomScale:[self minimumZoomScale] animated:YES];
            } else {
                CGRect zoomRect = [self zoomRectForScrollView:self withScale:self.maximumZoomScale withCenter:point];            
    
                [self zoomToRect:zoomRect animated:YES];
                //[self setZoomScale:[self maximumZoomScale] animated:YES];
            }
    
            [self setNeedsDisplay];
    
        }
    }
    

    Hope this will help.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.