I have a UIScrollView containing an UIImageView and I have some trouble to get the correct behavior when the iPhone rotates.
Goal: I am trying to o
I had a similar situation, a very simple scrollView with 3 imageViews ('previous', 'current', and 'next') to display a series of photos.
The photos were all sized for the iPad, but a mix of landscape and portrait orientations. I wanted them to fit into the screen, (i.e. letterboxed if necessary), with aspect ratio retained. I found I only needed to do this to the 3 imageViews for it to work:
imageView.contentMode = UIViewContentModeScaleAspectFit;
Try this:
scrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
imageView.contentMode = UIViewContentModeAspectFit; // You could also try UIViewContentModeCenter
I'm not sure if the imageView will get automatically resized within a UIScrollView, so if the autoresizing doesn't work, you could try setting the frame yourself on rotate to equal the size of the scrollview.