In our app, there is one ViewController should only be available in Portrait mode, hence we've used the usual way of making sure that only this mode works:
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
But if the user is in landscape mode before, and then switches to this specific ViewController, it does not rotate to Portrait mode automatically. Hence, we were looking for a way to force Portrait mode and found this:
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
forKey:@"orientation"];
It works fine, but since it's not an official way of doing things, we might get rejected now or in the future.
Is there a way to achieve the same result but with non-private APIs?
EDIT: I am specifically asking how to avoid using the solution posted in this question (How do I programmatically set device orientation in iOS7?), so how can it even possibly be a duplicate?