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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:49:44+00:00 2026-06-15T23:49:44+00:00

I am comfortable with pinch zooming functionality using UIScrollView. But the problem is the

  • 0

I am comfortable with pinch zooming functionality using UIScrollView. But the problem is the aspect fit of image in scrollview.

Currently, I am having this, below image:

enter image description here

But I want image to be fit in screen like below image:

enter image description here

And same behavior for landscape. How can I achieve this?

Below is the code:

- (void)viewDidLoad
{
    UIImage *image = [UIImage imageWithData:appDelegate.selectedOriginalImage];
    imgView.image = image;
    CGSize imageSize = image.size;
    CGRect rect = CGRectMake(0, 0, imageSize.width, imageSize.height);
    imgView.frame = rect;
    scrollView.contentSize = CGSizeMake(imgView.frame.size.width, imgView.frame.size.height);
    scrollView.maximumZoomScale = 4.0;
    scrollView.minimumZoomScale = 1.0;
    scrollView.delegate = self;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    UIImage *image = [UIImage imageWithData:appDelegate.selectedOriginalImage];
    CGSize imageSize = image.size;
    CGRect rect = CGRectMake(0, 0, imageSize.width, imageSize.height);
    imgView.frame = rect;

    [scrollView setContentOffset:CGPointMake(0, 0)]; 

    return YES;
}
  • 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-15T23:49:44+00:00Added an answer on June 15, 2026 at 11:49 pm

    You are setting the UIImageView to the original size of the image instead of the size of the UIScrollView that contains it.

    - (void)viewDidLoad
    {
        UIImage *image = [UIImage imageWithData:appDelegate.selectedOriginalImage];
        imgView.image = image;
    
        imgView.frame = scrollView.bounds;
        [imgView setContentMode:UIViewContentModeScaleAspectFit];
        scrollView.contentSize = CGSizeMake(imgView.frame.size.width, imgView.frame.size.height);
        scrollView.maximumZoomScale = 4.0;
        scrollView.minimumZoomScale = 1.0;
        scrollView.delegate = self;
    }
    

    remember to return the imgView on the viewToZoom delegate method

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

Sidebar

Related Questions

I used to be pretty comfortable with using jquery for json, but I'm having
I am quite comfortable using SQL but having an impossible time understanding SPARQL .
I am quite comfortable with generics and such, but in this special case I
I am now quite comfortable using autosizing masks in IB but there are two
I am comfortable with recording Coded UI tests using the VS2010 Ultimate. The problem
I want to install this . But I am not comfortable with composer. Is
I'm comfortable using git, but have been exploring Mercurial lately out of curiosity based
I'm fairly noobish at C++, but very comfortable with pointers, dereferencing, etc. I'm having
While trying to get comfortable with boost , stumbled into problem with using boost::function
I am not very comfortable using javascript so trying my hands to use this

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.