I have the following code to display a UIViewController in horizontal orientation ontop of a UITableViewController.
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterface开发者_开发技巧Orientation 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.
Try [self.view addSubview:landscapeChartViewController.view];
Assuming you've set your frames correctly, this should be what you're looking for.
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:
.
精彩评论