- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(270));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
[[self navigationController].view setTransform:landscapeTransform];
self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
self.navigationController.navigationBar.frame = CGRectMake(0.0, 20.0, 480, 44.0);
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(0));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
[[self navigationController].view setTransform:landscapeTransform];
self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320, 480);
self.navigationController.navigationBar.frame = CGRectMake(0.0, 20.0, 320.0, 44.0);
}
在这里,默认方向是纵向,但是当编译器转到 viewDidAppear 时,它将旋转 270 度,因此在横向模式下.. 相应地调整帧大小...
祝你好运 !!