Take the 2-minute tour ×

My app has navigation bar, where 1st screen returns YES to orientation, the second one is set to some orientation basing on what user choose in 1st screen. After going back to 1st screen from 2nd one, if user had device in hand in portrait but interface was in landscape, 1st screen is set to landscape. This happens because of


Is called only after changing device orientation.

I want to check what is device orientation atm and set interface orientation to this one. Tried:

//1st method:
UIViewController *rotateTheScreen = [[UIViewController alloc]init];
[self presentModalViewController:rotateTheScreen animated:NO];
[self dismissModalViewControllerAnimated:NO];
[rotateTheScreen release];

//2nd method:
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;

//3rd method:
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

1st is acting strange, rotates all cases besides coming back from interface orientation = landscape and device orientation = landscape (here is a bug, he rotates to landscape) 2nd checks interface, like the name tells, and tho doesnt work for my problem 3rd as far as i heard is private and Apple rejects apps using this.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Take a look at this thread. Basically, there's no way to force a device orientation and get your application approved by Apple.

Shortly, the method exists but is an undocumented method of the UIDevice class.

[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight animated:YES];

This gives a compiler warning that you can get rid of with a category.

@interface UIDevice (MyAwesomeMethodsThatAppleWillNeverAllowMeToUse)

Also, some say that you can call these methods indirectly using performSelector to get around Apple's static code analysis, as you can read in the comments here.

share|improve this answer

as I know there are no legal way. If I wrong, please, correct me somebody!

share|improve this answer

change the 'Initial interface orientation' in your project plist file

share|improve this answer
That won't solve the problem because he wants to rotate screen after app is launched. –  Nekto Sep 2 '11 at 7:42
Initial is only when you turn app on, my problem is i already turned it on and come back from different screen (1st paragraph of my question). Besides i need to set it to current device orientation not the one that i want. –  Vive Sep 2 '11 at 7:44
@Nekto Not he but she ;) However seems there is no legal method for it like you've said. Thanks for help! –  Vive Sep 2 '11 at 7:48
Excuse me, please, @Vive! –  Nekto Sep 2 '11 at 7:51

Your Answer


