title: UIScrollView with pages enabled and device rotation/orientation changes (MADNESS)
body: <p>I'm having a hard time getting this right.</p>
  
  <p>I've got a UIScrollView, with paging enabled. It is managed by a view controller (MainViewController) and each page is managed by a PageViewController, its view added as a subview of the scrollView at the proper offset. Scrolling is left-right, for standard orientation iPhone app. Works well. Basically exactly like the sample provided by Apple and also like the Weather app provided with the iPhone.</p>
  
  <p>However, when I try to support other orientations, things don't work very well. I've supported every orientation in both MainViewController and PageViewController with this method:</p>
  
  <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
       return YES;
  }
  </code></pre>
  
  <p>However, when I rotate the device, my pages become quite skewed, and there are lots of drawing glitches, especially if only some of the pages have been loaded, then I rotate, then scroll more, etc... Very messy.</p>
  
  <p>I've told my views to support auto-resizing with</p>
  
  <pre><code> theView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  </code></pre>
  
  <p>But to no avail. It seems to just stretch and distort my views.</p>
  
  <p>In my MainViewController, I added this line in an attempt to resize all my pages' views:</p>
  
  <pre><code>- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
  self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * ([self.viewControllers count]), self.scrollView.frame.size.height);
  
      for (int i = 0; i &lt; [self.viewControllers count]; i++) {
          PageViewController *controller = [self.viewControllers objectAtIndex:i];
          if ((NSNull *)controller == [NSNull null])
              continue;
  
          NSLog(@"Changing frame: %d", i);
          CGRect frame = self.scrollView.frame;
          frame.origin.x = frame.size.width * i;
          frame.origin.y = 0;
          controller.view.frame = frame;
      }
  }
  </code></pre>
  
  <p>But it didn't help too much (because I lazily load the views, so not all of them are necessarily loaded when this executes).</p>
  
  <p>Is there any way to solve this problem?</p>