title: How to rearrange programmatically created view on rotation?
body: <p><code>ViewControllerA</code> has a method <code>viewDidLoad</code> that programmatically creates a button like:</p>
  
  <pre><code>self.cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  self.cancelButton.frame = CGRectMake(330, 625, 125, 30);
  [self.cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
  [self.cancelButton sizeToFit];
  [self.cancelButton addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
  [self.cancelButton setNeedsDisplay];
  [self.view addSubview:self.cancelButton];
  </code></pre>
  
  <p>I also have <code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{return YES;}</code>.</p>
  
  <p>When the device is rotated to landscape, I want to change the button frame. I've tried checking <code>interfaceOrientation</code> in my <code>shouldAutorotate...</code> method above and setting the frame. I've tried doing <code>if (UIInterfaceOrientationLandscapeLeft == [[UIApplication sharedApplication] statusBarOrientation])</code> and resetting the frame there. None of this has worked. Any suggestions?</p>
  
  <p>EDIT</p>
  
  <p>Here's another attempt that produces no change:</p>
  
  <pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
    self.cancelButton.frame = CGRectMake(15, 15, 300, 50);
    } 
  }
  </code></pre>
  
  <p>So I tried doing:</p>
  
  <pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait
    || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      NSLog(@"Portait");
    } else {
      NSLog(@"Landscape");
    }
  }
  </code></pre>
  
  <p>And neither of the NSLogs get called, ever. My view is rotating though...</p>