First off, I have viewed many of the other threads on force portrait/landscape orientation for iOS.
I have a hybrid application that is built using IBM Worklight (I'm mainly focused on the iOS platform, since I have a solution already for Android that's working fine). I've added a cordova plugin to gain access to the device features. My application needs to be set to portrait on all screens except one. On one screen(view), I need to support landscape and portrait. However, when I navigate to another screen, I need to revert back to portrait only, but in my many attempts, its staying in landscape.
I'm using supportedInterfaceOrientations
and shouldAutorotate
methods to lock & unlock and switch between supporting only portrait or landscape & portrait.
Note: My application has only one view controller which contains the webview, so I can't use solutions to dismiss and present modal view controller.
I have also viewed other threads mentioning force rotation using transform in iOS, but that doesn't seem to work either. Is there a documented way to set the iPhone orientation?
(My app supports iOS7 and above) The only thing that has worked for me is
[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
and
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait );
However, Apple will reject my app if I use these because of private api.
Is there some other way to force an orientation to portrait while the device is rotated to landscape?