Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transform Navigation Bar and Navigation Controller in Landscape mode

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. :)

like image 847
Jyotsna Avatar asked Mar 02 '09 05:03

Jyotsna


1 Answers

#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];
}
like image 198
Michal Zaborowski Avatar answered Nov 10 '22 00:11

Michal Zaborowski