0

The iPhone has a orientation lock for portrait only. So I added a landscape orientation lock button to my UI that sets a landscape_orientation_locked variable to YES or NO. Then in shouldAutorotateToInterfaceOrientation: I basically do the following:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  if (landscape_orientation_locked)
    return (UIInterfaceOrientationIsLandscape(interfaceOrientation));

  return YES;
}

This works fine, except for one case. When I turn the iPhone to landscape orientation, toggle the orientation lock button, rotate the iPhone to portrait orientation and hit the button again. The interface orientation won't change from landscape to portrait. The iPhone has to be turned into landscape and then portrait orientation to trigger the interface rotation.

So my question is: Can I somehow 'force' the iPhone to re-evaluate it's current orientation?

Max
  • 11
  • 4

1 Answers1

0

Presenting and then dismissing a mock modal view controller should force an orientation check.

EDIT: Found the question where I first read about that:

Is there a documented way to set the iPhone orientation?

Community
  • 1
  • 1
Adis
  • 4,512
  • 2
  • 33
  • 40
  • I read about that trick, as well. Unfortunately it doesn't seem to work (anymore?). – Max Jun 04 '12 at 12:37