title: How to rotate and resize UIView on device rotation
body: <p>I have a UINavigationController application where the user makes several selections on several navigation views. then on the final view I allow the user to see the information that was defined by their selections from the previous views. This information is presented in subviews on the finalview of the NavigationController stack.</p>
  
  <p><strong>example:</strong></p>
  
  <pre><code>UINavigationController
  - Several Views including (final view)
  Final View 
  - several Subviews
  </code></pre>
  
  <p>When The final View loads I create a deviceOrientation listener which executed the didRotate method.</p>
  
  <pre><code>[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
  
  [[NSNotificationCenter defaultCenter] addObserver:self
                                               selector:@selector(didRotate:)
                                                   name:UIDeviceOrientationDidChangeNotification
                                                 object:nil];
  </code></pre>
  
  <p>I then call a method called currentView which is used to figure out which subview is currently visible. i.e. this is called when ever i have something like a [finalview.view addSubView:firstView.view]</p>
  
  <pre><code>[self copyCurrentView:@"firstView"];
  
  
  - (void)copyCurrentView:(NSString *)currentView {
  
      myCurrentView = currentView;
  
  }
  </code></pre>
  
  <p>Now when the device is rotated this method is triggered</p>
  
  <pre><code>-(void)didRotate:(NSNotification *)notification
  {
      UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
  
      if (orientation == UIDeviceOrientationLandscapeLeft)
      {
          if ([myCurrentView isEqualToString:@"firstView"]) {
  
             [self.navigationController.view insertSubview:firstView.view aboveSubview:self.navigationController.navigationBar];
             [self.navigationController  setNavigationBarHidden:YES animated:YES];
  
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
             [firstView.view setBounds:CGRectMake(0, 0, 480.0, 320.0)];
             [firstView.view setCenter:CGPointMake(320/2, 480/2)];
             [firstView.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
          }
       //other if statments here
  
  
      }
      else if (orientation == UIDeviceOrientationLandscapeRight)
      {
        // do the same here
      }
      else if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
      {
          NSLog(@"@port");
  
       if ([myCurrentView isEqualToString:@"firstView"]) {
          [self.view insertSubview:firstView.view belowSubview:actionTabBar];
          [self.navigationController  setNavigationBarHidden:NO animated:YES];
  
  
  
          [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
          [firstView.view setBounds:CGRectMake(0.0, infoBarHeight, firstView.view.bounds.size.width, firstView.view.bounds.size.height)];
  //        [firstView.view setCenter:CGPointMake(480/2, 320/2)];
          [firstView.view setTransform:CGAffineTransformMakeRotation(M_PI * 2)];
        }
      }
  }
  </code></pre>
  
  <p>Now this looks a little scrappy and probably a really random way of doing it.. however from everything I Have found online i cannot figure out how to get a good effect.</p>
  
  <p>currently when i rotate the device left it goes full screen perfectly.. exactly like i want
  HOWEVER when i rotate to portrait again it never goes back to the original position even though I am using the correct sizing etc.</p>
  
  <p>if anyone could help me set up a MODEL view on rotation for what ever subview is currently visible that would be greatly appreciate.</p>
  
  <p>I have been hesitant to ask this question as to me its very hard to explain in an understanding manner.. but I Have done my best to explain what I Have done and what I need help with as best as I can.. Hopefully someone can help me.</p>
  
  <p>regards</p>