iphone force portrait mode from landscape?
I have a complicated structure where I have a c开发者_运维技巧ustom tab-bar controller that houses multiple navigation controllers. Some of these sub-navigation controllers only support portrait mode so I just turn off rotation when I get to them. When I come into the new navigation controller and it is in landscape is there a way to force auto-rotation to portrait at that time?
You can try the undocumented method setOrientation:
from the UIDevice
class. Here is one example:
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
You will have one compiler warning, ignore it.
I do not have problem with Apple rejection using this method, so until now it works.
Apple is no longer allowing private method calls, they're running the apps through static analysis now when they're submitted. If you submit a new app using [[UIDevice currentDevice] setOrientation:]
it will be rejected.
精彩评论