IOS Force Device вращение - PullRequest
       18

IOS Force Device вращение

1 голос
/ 21 сентября 2011

вот мой код:

  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];
  }

и при этом из портретного режима новый контроллер просмотра показывается в режиме альбомного лева, и все в порядке, но моя проблема заключается в следующем: если я поворачиваю устройство из ландшафтного режима в портретном режиме, строка состояния появляется в портретном режиме, а viewcontroller остается в ландшафтном режиме ....

как я могу решить это? заранее спасибо!

1 Ответ

4 голосов
/ 21 сентября 2011

Вы можете повторно реализовать метод shouldAutorotateToInterfaceOrientation и сделать что-то вроде

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

Таким образом, вы активируете только левую ориентацию и, если вы поворачиваете устройство в портретное положение, интерфейс не будет вращаться

...