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 に答える