I have a really strange orientation issue. I have a sequence of view controllers under a navigation controller. One of them can take any orientation. When I'm leaving the orientation I have to use setOrientation. The funny thing is the rotation takes place as the transition occurs to the next page. This isn't normally a problem except for a single case -- from UIDeviceOrientationPortraitUpsideDown to normal causes all my top mounted items to migrate up about an eighth of a page.
There are three ways I think I could fix it:
Here's my push the new view onto the stack code:
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
ResultSelect_ViewController *resultSelect = [[ResultSelect_ViewController alloc] initWithNibName:@"ResultSelect" bundle:nil];
[self.navigationController pushViewController:resultSelect animated:YES];
Anybody else find it odd that the simulator doesn't allow you to test the upside down to portrait behavior?
The way to avoid the rotation bug when rotating from upside down to portrait is not to do it. Instead, rotate twice stopping halfway (say UIDeviceOrientationLandscapeRight
). The question of timing is not to use sleep but instead implement didRotateFromInterfaceOrientation
and fire the second rotation (or push to next view) at that point.