1

这是我的代码:

  if ([[UIApplication sharedApplication] statusBarOrientation] != UIInterfaceOrientationLandscapeLeft) {
      [appDelegate makeTabBarHidden:TRUE];
      self.navigationController.navigationBarHidden = YES;
      [UIView beginAnimations:@"newAlbum" context:NULL];
      [UIView setAnimationDelegate:self];
      [UIView setAnimationDidStopSelector:@selector(addResultGraph)];
      [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
      // Then rotate the view and re-align it:
      CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation( 90.0 * M_PI / -180.0 );
      landscapeTransform = CGAffineTransformTranslate( landscapeTransform, +90.0, +90.0 );
      [self.navigationController.view setTransform:landscapeTransform];
      [UIView commitAnimations];
  }

有了这个,从纵向模式,新的视图控制器以横向模式显示,一切都很好,但我的问题是:如果我从横向模式以纵向旋转设备,状态栏以纵向模式出现,而视图控制器保持在横向模式....

我该如何解决这个问题?提前致谢!

4

1 回答 1

4

您可以重新实现shouldAutorotateToInterfaceOrientation方法并执行类似的操作

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

这样,您只启用左方向,如果您将设备旋转为纵向,界面将不会旋转

于 2011-09-21T15:36:37.490 回答