Search code examples
iphoneobjective-ccocoa-touchuiscrollviewuiimageview

How to autorotate UIScrollView and UIImageView programmatically?


I have a UIScrollView and a UIImageView which I have created programmatically without interface builder. How can I make sure both auto-rotate in horizontal orientation?


Solution

  • If you're subclassing UIViewController, even programmatically, you should get rotation for free. Just make sure you set the autoresizingMask on the scroll view and image view so that the mask is set to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight if you want the view to adapt to the new screen dimensions.