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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:44:25+00:00 2026-06-07T11:44:25+00:00

I have a UIImageView embedded in a UIScrollView … When the image is loaded

  • 0

I have a UIImageView embedded in a UIScrollView… When the image is loaded the zoom scale is set so that the maximum amount of the image is visible, however when the device is rotated the aspect is not maintained and ends up appearing stretched. Mode for views is set to redraw.

- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView.delegate = self;
// get the url of the photo from flickr
NSURL* url = [FlickrFetcher urlForPhoto:self.photo format:FlickrPhotoFormatLarge];
// set the scrollview's title to be the title of the picture
self.title = [self.photo objectForKey:FLICKR_PHOTO_TITLE];
// convert the url into an image
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
// set the image as the image in the imageView
[self.imageView setImage:image];
// we will be scrolling over the size of the image
self.scrollView.contentSize = self.imageView.image.size;
}

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIInterfaceOrientation currOrient = self.interfaceOrientation;
self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
if (currOrient == UIInterfaceOrientationPortrait || currOrient == UIInterfaceOrientationPortraitUpsideDown)
    [self.scrollView setZoomScale: self.scrollView.frame.size.height / self.imageView.frame.size.height];
else {
    [self.scrollView setZoomScale: self.scrollView.frame.size.width / self.imageView.frame.size.width];

}
//     [self.imageView setNeedsDisplay];
// [self.scrollView setNeedsDisplay];

}

-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
scrollView.transform = CGAffineTransformIdentity;
}
  • 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-07T11:44:27+00:00Added an answer on June 7, 2026 at 11:44 am

    In your controller you will have to implement:

    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
    

    Set your zoom scale there as an animation of viewWillAppear.

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

Sidebar

Related Questions

I have a UIImageView whose frame, set before the image is loaded, is always
I have an UIImageView inside an UIScrollView. I want that the user can zoom
I have a UIImageView which has a png image sequence loaded into it. My
I have a UIImageView showing a image that is larger than it's frame. It's
I have a UIImageView that starts off with an image (loading.png) specified in IB.
I have a UIImageView, and a referencing outlet. However, altough I've set User Interaction
I have a UIImageView that I've added a PinchGestureRecognizer to. Currently, the image is
I have an UIImageView on my view. Certain parts of that image, I want
I have my NSTimer embedded in a class that plays image sequences. Basically it
I have a UIImageView inside of my UIViewController. It loads an image that is

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.