Search code examples
iphoneuiscrollvieworientationlandscapeportrait

Restrict images in scroll view to stretch when iPhone moved to landscape orientation


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!


Solution

  • 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.