UIScrollView won't autorotate
- by clozach
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.