Sheehan Alam
Sheehan Alam

Reputation: 60919

Rotating UIViewController Problem

I have the following code to display a UIViewController in horizontal orientation ontop of a UITableViewController.

  -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [self.view addSubview:landscapeChartViewController.view];
    }

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
        toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        if(landscapeChartViewController != nil)
            [landscapeChartViewController.view removeFromSuperview];
    }
}

When the phone rotates, the view doesn't take up the entire screen.

The user is also able to scroll, thus showing the rest of the UITableViewController. I don't want the UITableViewController to be there in horizontal orientation.

Upvotes: 0

Views: 195

Answers (2)

tc.
tc.

Reputation: 33602

landscapeChartViewController.view.frame = self.view.bounds, perhaps?

Also keep in mind that the orientation change can happen "in the background" if you're using a tab bar controller, so you might also want to check the current orientation in -viewWillAppear:.

Upvotes: 0

FeifanZ
FeifanZ

Reputation: 16316

Try [self.view addSubview:landscapeChartViewController.view];

Assuming you've set your frames correctly, this should be what you're looking for.

Upvotes: 1

Related Questions