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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:26:21+00:00 2026-05-23T10:26:21+00:00

I have an UIImageView with an image (map) inside of a UIScrollView. I add

  • 0

I have an UIImageView with an image (map) inside of a UIScrollView. I add another image (marker) to the image view (so a map background and a marker). If the marker isn’t shown on the screen, when I place the marker I want to scroll to show the marker.

I’m using [scrollView scrollRectToVisible:rect animated:YES] after I place the marker on the map. This works great when the scrollview isn’t zoomed. How do I adjust rect based on the zoom scale so the marker is centered in the view?

  • 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-23T10:26:22+00:00Added an answer on May 23, 2026 at 10:26 am

    I do something very similar in the app I am currently working on, but instead of using -scrollRectToVisible, I use -setContentOffset.

    Because I know where my marker is in the frame, I can easily calculate its center, which I save as the CGFloats centerX and centerY. I then use the following code to center the marker on the screen (I subtract 161 from the Y value because my main view has a tab bar and a navigation controller, so it is not the full 480 points):

    CGFloat curZoom = scrollView.zoomScale;
    
    [scrollView setContentOffset:CGPointMake((centerX*curZoom)-160, (centerY*curZoom)-161) animated:NO];
    

    By multiplying the center point by the current zoomScale, I can find the correct center point regardless of zoom level.

    My marker is a subview of the UIImageView that holds my map. It sounds like you are doing it the same way, so I imagine this (or something similar) should work for you.

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

Sidebar

Related Questions

I have two UIImageView objects inside my view (both 320x480 one above the other).
The thumbnail image shown in the info view of Maps app is UIImageView or
I have an UIImageView inside an UIScrollView. I want that the user can zoom
i have a view with uiimageview i assign this uiimageview image by camera..now i
i have a UIImageView displayed in my view with an image image1 already set.
I have a UIImageView with an image already set, and try to add a
I have a UIImageView showing a image that is larger than it's frame. It's
I have a UIImageView which has a png image sequence loaded into it. My
I have a UIImageView that starts off with an image (loading.png) specified in IB.
I have a UIImageView with an image in it. I have rotated the image

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.