views:

18

answers:

0

We have a simple view based application we're building for the iPad. We're doing a custom UI so everything is being done programmatically. At the moment our view heirarchy looks something like this:

UIViewController -> UITableViewController -> TableView

We want to transition to the UITableViewController's TableView when an event fires. Currently we are doing this by adding UITableViewController's TableView as a subview of the UIViewController:

[self.view addSubview:tvc.tableView animated:YES];

This works, however, I'm not sure this is the proper way to do this. We are now encountering issues with resizing the TableView. In our ViewController we have code to resize our subViews based on the orientation.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{
  NSArray *dimensions = [self getWidthAndHeightForOrientation: toInterfaceOrientation];
  float height = [[dimensions objectAtIndex:0] floatValue];
  float width = [[dimensions objectAtIndex:1] floatValue];
  if (tvc != nil) {
    [tvc.tableView setFrame:CGRectMake(0, 0, width, height)];
  }
}

The problem is when the tableView initializes it fits the screen of the orientation. When the screen rotates the tableView becomes half the size of the screen, or half the height of the screen revealing the main view beneath it. We have logged the tableView's frame dimensions after the routine runs and the dimensions are being set correctly. We can't explain why the tableView's frame is not reflecting the dimensions we are setting. Is it because our TableViewController is conflicting with our main ViewController.

I am relatively new to iPhone Development so I was also curious to know if we should incorporate a UINavigationController to push the TableViewController as opposed to adding the TableView property as a subview to our main UIViewController.

Thanks!