title: Rotation with Different Layouts - iOS 4
body: <p>The following are the two layouts that I want have in my application.  It would be nice if when the application switches from portrait to landscape that it keeps the UILabels, BOOLs, and other objects. Because the buttons are situated differently I cannot just have the portrait view autoresize on an auto rotate. I also want to implement my own rotation lock using a BOOL and the button on the top right.</p>
  
  <p>I thought about using a <em>-(void)orientationChanged:(NSNotification )notification</em> with a <em>presentModalViewController</em> however these didn't copy over the objects and seemed to cause <a href="https://stackoverflow.com/questions/5764850/rotation-problems-using-2-xibs-and-1-view-controller-ios">more harm then good and didn't appear to work properly</a>.</p>
  
  <p>Thanks for the help!</p>
  
  <p><img src="https://i.stack.imgur.com/qrLtT.png" alt="Portrait xib">
  <img src="https://i.stack.imgur.com/gwx0z.png" alt="Landscape xib"></p>
  
  <p><strong>Attempted Solutions:</strong></p>
  
  <p>I added the landscape view to the ViewController, having both views in the view controller. I linked it up to File's Owner under the UIView *landscapeView that I added in the @interface section of the ViewController. I added [self.view addSubview:landscapeView] to the viewDidLoad method.  Then I added this piece of code:</p>
  
  <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
      if (orientationLock)
          return NO;
      else {
          if (interfaceOrientation == UIInterfaceOrientationPortrait) {
              [landscapeView setHidden:YES];
              //[self.view setHidden:NO]; removed
          } else {
              //[self.view setHidden:YES]; removed
              [landscapeView setHidden:NO];
          }
          return YES;
      }
  }
  </code></pre>
  
  <p>However this is not the correct solution. When I run the simulator and rotate it, the screen is not properly placed.</p>
  
  <p><img src="https://i.stack.imgur.com/XWOcw.png" alt="Bad Image"></p>