I am developing a game in which I am using Landscape mode I have total 4 view. 2 views are properly coming in Landscape mode. But in third view I have UITable and Navigation bar. I can able to rotate table in landscape mode but not able to transform Navigation bar and Navigation controller. Navigation bar and Navigation Controller also have Button on it. It also not get transformed. So can anyone have the solution on this. :)
5
votes
3 Answers
7
votes
#define degreesToRadians(x) (M_PI * x / 180.0)
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
CGRect newBounds = CGRectMake(0, 0, 480, 320);
self.navigationController.view.bounds = newBounds;
self.navigationController.view.center = CGPointMake(newBounds.size.height / 2.0, newBounds.size.width / 2.0);
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
self.navigationController.view.transform = CGAffineTransformIdentity;
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);
[super viewWillDisappear:animated];
}
2
votes
1
votes
In UIViewController documentation's Class:
Handling Rotations
interfaceOrientation property
– shouldAutorotateToInterfaceOrientation:
– rotatingFooterView
– rotatingHeaderView
– willRotateToInterfaceOrientation:duration:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
hope this helps you too.
A.