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

The Archive Base Latest Questions

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

Hi, I have a big image and small image over it at a specific

  • 0

Hi, I have a big image and small image over it at a specific location…
I added them all under ScrollView, but it didn’t work properly?
I want to zoom in, all together each in its place

Here is my code:

    myScrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
    myScrollView.maximumZoomScale = 3.0;
    myScrollView.minimumZoomScale = 1.0;
    myScrollView.clipsToBounds = YES;
    myScrollView.delegate = self;

    [myScrollView addSubview:imageView];

thanks


Hi, mackworth; I did it, but if I didn’t maximize the image, I can’t move the scroll view anywhere, but if I zoomed it, I can see the rest.. I don’t know why I tried changing it, but it work. Can you please look at the following code?

- (void)viewDidLoad{
    [super viewDidLoad];
    UIImage *image = [UIImage imageNamed:@"ucd.png"];
    //creating a view for UCD image
    ucdView = [[UIImageView alloc] initWithImage:image];
    //setting the frame for the ucdView as the same size of ucd image
    [ucdView setFrame:CGRectMake(0, 0, image.size.width, image.size.height)];


    //for the red pin to display in specific loc
    UIImageView *Health = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"redPin.png"]];
    [Health setCenter:CGPointMake(310,135)];
    //adding helathView to ucdview
    [ucdView addSubview:Health];
    //everything for scroll view
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, ucdView.frame.size.width, ucdView.frame.size.height)];
    [scrollView setMinimumZoomScale:1.0];
    [scrollView setMaximumZoomScale:3.0];
    scrollView.clipsToBounds = YES;
    [scrollView setContentSize:CGSizeMake(image.size.width, image.size.height)];
    [scrollView setDelegate:self];
    [scrollView addSubview:ucdView];//adding ucd view to scroll view
    [self.view addSubview:scrollView]; // adding scrollview to self.view main view
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {//apply zooming for scrollview
    return scrollView;
}    
  • 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:46:12+00:00Added an answer on May 23, 2026 at 10:46 am

    Did you implement:

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

    Also, you know that by setting the scrollView’s contentSize to your imageSize, it can’t grow any bigger than that, right? It’ll zoom in place, cropping the outer pixels accordingly. As an aside, if that is your plan, why not just set it directly?

    myScrollView.contentSize = imageView.frame.size;
    

    =====Further answer, responding to additional source

    Well, the main thing I notice is that you need to return the imageView ucdView in viewForZoomingInScrollView, not the scrollView. It looks like you already created ucdView as a property (so that it lives as long as your view does), but just in case…

    1) In your .h file:

    UIImageView * ucdView;
    @property (nonatomic, retain) UIImageView * ucdView;
    

    2) In your .m file;

    @synthesize ucdView;
    

    3) change your line:

    ucdView = [[UIImageView alloc] initWithImage:image];
    

    to just

     self.ucdView = [[UIImageView alloc] initWithImage:image];
    

    4) change the line

     return scrollView
    

    to:

     return self.ucdView;
    

    5) Add the following to your dealloc routine:

    self.ucdView = nil;
    

    Also, did you add <UIScrollViewDelegate> protocol to your ViewController definition (in .h file)?

    Finally, you have a leak of scrollview and Health; add [scrollView release]; and [Health release] at end of viewDidLoad

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

Sidebar

Related Questions

I have taken an image from UIImagePickerController , but the file looks too big
I'm currenty writing small application for image processing. However I have a big problem
I have a big image that has to go in the background. Say the
I have a piece of code that load a very big image in memory.
I have an image that is too big and I want to put it
I have big problem when I am trying to deploy my app over clickonce.
I have a simple setup with one big image container and 3 smaller thumbnail
I want to show a big Image when I press the small thumbnail. A
I have a div with a specific width and height. And a smaller image
I have a big UIimage (2000x2000). Image drawed every time on app start, and

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.