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?
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.
make sure you have implemented shouldAutorotateToInterfaceOrientation and then do a little
yourView.transform = CGAffineTransformIdentity;
yourView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
and using this in your header files can be very useful
#define degreesToRadian(x) (M_PI * (x) / 180.0)
精彩评论