Question

here is my code:

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

and with this, from a portrait mode, the new viewcontroller is shown in landscapeleft mode, and everything is ok, but my problem is: if I rotate the device from landscape mode in portrait, the statusbar appears in portrait mode and the viewcontroller remains in landscape mode....

how can I solve this? thanks in advance!

Was it helpful?

Solution

You may re-implement shouldAutorotateToInterfaceOrientation method and do something like

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

This way you enable only left orientation and, if you rotate your device to portrait, the interface won't rotate

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top