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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:13:13+00:00 2026-05-30T13:13:13+00:00

I am trying to zoom into a UIImage so I can see as much

  • 0

I am trying to zoom into a UIImage so I can see as much of the photo as possible without showing white space. Thus in portrait I want to zoom so that the shorter of the two sides of the image fits fully in the screen. All of the following code is in viewDidLoad.

I have the UIImageView and UIScrollView set up as follows:

self.scrollView.delegate = self;
self.scrollView.contentSize = self.imageView.image.size;
self.imageView.frame = CGRectMake(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);

At this point zooming and scrolling within the UIScrollView works perfectly.

Then I implement an if-else so that when the picture is taller than it is wide I call:

[self.scrollview zoomToRect:CGRectMake(0, 0, IMAGE_WIDTH, 1)];

This works perfectly. The width of the image fills the width of the screen and I can only scroll up and down.

But when I call the exact same function for the height:

[self.scrollview zoomToRect:CGRectMake(0, 0, 1, IMAGE_HEIGHT)];

Nothing! No zoom at all as if the function was never called. But I set a breakpoint and stepped through the code in the debugger and everything was called perfectly, even the CGRectMake function itself. What’s going on?

  • 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-30T13:13:14+00:00Added an answer on May 30, 2026 at 1:13 pm

    As per the comments above, make sure you select a rect with both a width and a height for the given aspect ratio you want to zoom to.

    [self.scrollview zoomToRect:CGRectMake(0, 0, IMAGE_WIDTH * WIDTH_OF_VIEW / HEIGHT_OF_VIEW, IMAGE_HEIGHT)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to zoom into the area of the DirectShow window between Marker A
I'm experimenting with the CSS zoom property, and I'm trying to basically zoom into
I can't zoom to a marker properly. I'm trying to switch the view to
I am trying to use the reChart tool in quantmod to zoom into my
I'm trying to use a zoom plugin for interactive maps I put everything into
I am trying to save the edited UIscrollView into UIImage using following code. But
I'm trying to zoom into the user location as the center reference for the
I'm trying to zoom a map into the user's current location once the view
Im trying to create a simple pan and zoom app using silverlight 4, but
I'm trying to replace the zoom functionality with scroll on my microsoft ergonomic keyboard

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.