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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:26:11+00:00 2026-05-28T06:26:11+00:00

I was writing a simple custom View Controller in ios5 with a UIScrollView and

  • 0

I was writing a simple custom View Controller in ios5 with a UIScrollView and an embedded UIImageView, with the intention of displaying photos and being able to do zooming and panning.
These are all embedded in a UINavigationController and TabBarViewController

Here are snippets of my code:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.scrollView.delegate = self; 
    self.imageView.image = self.image;
    [self.imageView sizeToFit]; 
    self.scrollView.zoomScale = 1;
    self.scrollView.contentSize = self.imageView.image.size;
    NSLog(@"Original contentSize=(%f,%f), ratio=%f", self.scrollView.contentSize.width, self.scrollView.contentSize.height, self.scrollView.contentSize.height/self.scrollView.contentSize.width);
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{
    return self.imageView;
}

- (void) scrollViewDidZoom:(UIScrollView *)scrollView 
{
    NSLog(@"Changed contentSize=(%f,%f), ratio=%f", self.scrollView.contentSize.width, self.scrollView.contentSize.height, self.scrollView.contentSize.height/self.scrollView.contentSize.width);
}

I’ve also defaulted the View->Mode in the Attributes inspector to “Top Left” for both the UIScrollView and UIImageView. Zoom min/max has been set to 0.1/10. Delegates and outlets are hooked up.

Now when i run my program, this is what I get when I pinch-zoom on the image:

2012-01-08 19:58:33.529 TestApp[499:f803] Original contentSize=(1024.000000,1024.000000), ratio=1.000000
2012-01-08 19:58:37.599 TestApp[499:f803] Changed contentSize=(1014.381775,922.255310), ratio=0.909180
2012-01-08 19:58:37.600 TestApp[499:f803] Changed contentSize=(1014.381775,922.255310), ratio=0.909180
2012-01-08 19:58:37.730 TestApp[499:f803] Changed contentSize=(1004.763977,913.510986), ratio=0.909180
2012-01-08 19:58:41.432 TestApp[499:f803] Changed contentSize=(974.770325,886.241394), ratio=0.909180
2012-01-08 19:58:41.433 TestApp[499:f803] Changed contentSize=(974.770325,886.241394), ratio=0.909180
2012-01-08 19:58:41.448 TestApp[499:f803] Changed contentSize=(954.777161,868.064026), ratio=0.909180

As you can see, the ratio of the heigh and width of the contentSize changes when I zoom. Does anyone know why this is the case? Am I doing something wrong here? Do I have to manually set the contentSize in scrollViewDidZoom?

  • 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-28T06:26:12+00:00Added an answer on May 28, 2026 at 6:26 am

    As mentioned in my comment, I fixed this by setting the frame.size of the scrollView to (320,367). It was set incorrectly by the storyboard.

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

Sidebar

Related Questions

I'm writing a simple CMS. I want to be able to load a View,
I am writing a simple custom work item browser and I'd like it to
Is there a relatively simple way in nant, without writing a custom task, to
I'm writing a simple custom owner-drawn ListBox control and banging my head against the
What is the benefit of writing a custom LINQ provider over writing a simple
I'm writing a simple custom function in Facelets with a sample method. The problem
I'm writing a very simple application to open my custom share dialog. XML layout
I'm writing simple program to communicate between smart devices and I receive 11001 when
I'm looking into writing simple graphics code in Android and I've noticed some synchronized()
I am writing simple site that requires users and profiles to be handled. The

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.