0

I have imageViews as content for in the UIScrollView. If a user is viewing a potrait picture (320x480) and moves the iPhone in landscape orientation - the image stretches to occupy full screen. I want to restrict the image to stretch. I want a functionality similar to the photos app where image is scaled down and shows black strips in left and right.

Anyone with any suggestion how I can achieve this - would be a great help!

AJ.
  • 1,443
  • 7
  • 19
  • 31

1 Answers1

0

When you rotate, instead of letting your UIIMageView expand, resize its frame to be what you want it to be...that should take care of it.

Daniel
  • 22,363
  • 9
  • 64
  • 71
  • Yes - I figured that out just after posting the question. But I guess I will have to scale the image too. Otherwise it shows only a part of the image. Any idea how can I do that? – AJ. Jul 31 '09 at 13:28
  • Got it to work! Though the fix is not related to the view resize. All I had to do was add this line
     view.contentMode = UIViewContentModeScaleAspectToFit; 
    THis thing would take care of it all.
    – AJ. Jul 31 '09 at 14:10
  • This can also be done in Interface Builder, by selecting "Aspect Fit" from "Mode" under the "View" section. – rid Jan 18 '13 at 15:16