0

I want to force my view to go for landscape, just when I call a method.

When my method runs I call:

[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)UIInterfaceOrientationLandscapeRight];

Method to autorotate

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

The problem is that the view don't force the rotation. Is possible to test it on the simulator, or just works in real device?

88fsantos
  • 393
  • 1
  • 7
  • 22

1 Answers1

1
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
lobianco
  • 6,226
  • 2
  • 33
  • 48
  • I've one problem. The view that I created inside, is not set to landscape :S Now it should have 480 width and 320 height, right? But it doesn't :S – 88fsantos Jun 14 '12 at 18:25
  • 1
    It sounds like you need to create a view with a relative size. So instead of creating a view with `initWithFrame:CGRectMake(0, 0, 320, 480)]`, try something like `initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height])` – lobianco Jun 14 '12 at 18:33