How to change the device orientation programmatically in iOS 6 [duplicate]

Here are my “five cents”, tested on iOS7 with ARC

[[UIDevice currentDevice] setValue:
                      [NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
                            forKey:@"orientation"];

This doesnt generate “leak” warning as performSelector will.

UIAlertView – with this code, when you open UIAlertView during view(will/Did)appear you will notice that all but this view is in portrait (apple, really?) I wasn’t able to force the view to reorient but found that if you put slight delay before opening the UIAlertView then view has time to change orientation.

Note I’m releasing my app week commencing 12/09/2014 and I will update post if it will pass or fail.

Leave a Comment