title: iOS Sizing UITableView During Orientation Change
body: <p>I have a view that has two tables. In the story board, I have two separate views, one horizontal and the other vertical. When I need to navigate to the view, the code detects the orientation and brings up the appropriate view (and does so on an orientation change.</p>
  
  <p>I have the following code in my method:</p>
  
  <pre><code>-(void)viewDidAppear:(BOOL)animated{
      UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
      if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){
      if(tableHeight2 &gt; 324){
          tableHeight2 =325;
      }
      table1.frame = CGRectMake(table1.frame.origin.x, table1.frame.origin.y, table1.frame.size.width, tableHeight1);
      table2.frame = CGRectMake(table2.frame.origin.x, table1.frame.origin.y + 20 + tableHeight1, table2.frame.size.width, tableHeight2);
  }else {
      if(tableHeight2 &gt; 500){
          tableHeight2 = 500;
      }
      table1.frame = CGRectMake(table1.frame.origin.x, table1.frame.origin.y, table1.frame.size.width, tableHeight1);
      table2.frame = CGRectMake(table2.frame.origin.x, table1.frame.origin.y + 50 + tableHeight1, table2.frame.size.width, tableHeight2);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This works wonderfully when I press a button to navigate to the view. It adds up all of the cell heights and makes the first table the appropriate height, then moves the second table 50  pixels below the first table. It also makes sure the second table doesn't extend beyond the visible screen area.</p>
  
  <p>When the orientation changes, I the following code is executed:</p>
  
  <pre><code>-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
  
      InitViewController *ini;
      ini = [self.storyboard instantiateViewControllerWithIdentifier:@"Init"];
      ini.location = MenuName;
      [self presentViewController:ini animated:NO completion:nil];
  }
  </code></pre>
  
  <p>This <em>should</em> do the same thing that pressing a barbuttonitem does: change to InitViewController while sending the StoryboardID to it in the ini.location variable. The code for the navigation buttons is pretty much identical to the code in willAnimateRotationToInterfaceOrientation. InitViewController then determines the orientation and sends the app to the correct storyboard UIView.</p>
  
  <p>It does send it to the right view, I can tell based on the table widths. What it <em>doesn't</em> do is change the height of the first (top) table, table1. The first table retains the size it was given in the storyboard.</p>
  
  <p>If there is area of code you think I need to post to get a better picture, let me know I'll be happy to add it. Any help, insight, or even just trial-and-error suggestions would be appreciated.</p>
  
  <p>*Note: I have tried to change willAnimateRotationToInterfaceOrientation to ViewDidLayoutSubviews, to not effect.</p>