UIScrollView won't autorotate

Posted by clozach on Stack Overflow See other posts from Stack Overflow or by clozach
Published on 2009-12-13T10:14:35Z Indexed on 2010/05/05 7:58 UTC
Read the original article Hit count: 581

Filed under:
|
|

My app design requires the same scrolling functionality found in the iPhone's native Photos app when browsing photos in full screen. Specifically:

  • Each view snaps into place as the view is swiped
  • Scrolling happens in only one direction
  • Rotating the iPhone rotates the entire scrolling region as well such that the frame of each subview (photos, in Apple's case) rotates in-place and paging is still in the same direction (left-to-right)

I started to use Apple's sample PageControl code as a launching point, and everything was going swimmingly until I attempted adding autorotation to the code. My sense from the docs was that all I had to do to get autorotation working was to add this to the sample code's MyViewController.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 return YES;
}

While that does seem to cause the subviews' backgrounds to rotate, the UILabels and the enclosing UIScrollView stay fixed so that, from a user perspective, paging through the views now requires up/down flicking instead of left/right.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiscrollview