- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
float navBarHeight = self.navigationController.navigationBar.frame.size.height;
float tabBarHeight = ((UITabBarController *)self.navigationController.parentViewController).tabBar.frame.size.height;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
float statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.navigationController.navigationBar.hidden = YES;
((UITabBarController *)self.navigationController.parentViewController).tabBar.hidden = YES;
// TabBarController adjustments
self.navigationController.parentViewController.view.bounds = CGRectMake(0, -tabBarHeight/2, 480, 320 + tabBarHeight);
// Adjust view
self.view.frame = CGRectMake(0, -statusBarHeight - navBarHeight, 480, 320);
// Adjust web view
self.WebView.frame = CGRectMake(26, 0, 426.6667, 320);
}
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
float statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
self.navigationController.navigationBar.hidden = NO;
((UITabBarController *)self.navigationController.parentViewController).tabBar.hidden = NO;
// TabBarController adjustments
self.navigationController.parentViewController.view.bounds = CGRectMake(0, 0, 320, 480);
// NavigationController adjustments
self.navigationController.navigationBar.frame = CGRectMake(0, statusBarHeight, 320, navBarHeight);
// Adjust view
self.view.frame = CGRectMake(0, statusBarHeight + navBarHeight, 320, 480 - statusBarHeight - navBarHeight - tabBarHeight);
// Adjust web view
self.WebView.frame = CGRectMake(0, 0, 320, 240);
}
}