1

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!

1
  • works fine if I block the iphone rotation (absolute)
    – ghiboz
    Sep 21, 2011 at 21:16

1 Answer 1

4

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

2
  • thanks, i've tried but the method is not called and seems to not properly work...
    – ghiboz
    Sep 21, 2011 at 20:33
  • ok, solved, i return false, 'cause the rotation it's me that implement, not autorotate
    – ghiboz
    Sep 26, 2011 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.