In a tab based application, say the device is physically in landscape orientation and fixed in that orientation. One tab should only present in portrait, to force that orientation when user switching tab we do
[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationPortrait) forKey:@"orientation"];
After this, is there a way by which we can still find that device is physically landscape, so when user returning to landscape supported view, we can update "orientation" with right landscape value? because UIDevice->currentDevice->Orientation starts to report as Portrait since we updated that. I couldn't find anything else that could tell the fact that device is physically in landscape orientation.
Am i missing something?
You can still get the rotation by using gyroscope I guess.
But you should not be doing any of this. You need to use restriction per view controller (which I assume you tried but did not work). Once you have per view controller orientation locked ensure that message is forwarded correctly on embedded view controllers.
That means that each
UINavigationViewControllershould be overridden and return the settings of its top view controller. It also means everyUITabBarControllershould do the same using its currently shown view controller. And in real situations you may have a navigation controller holding a tab bar view controller showing another navigation controller having its currently visible view controller. And even in this case you must ensure that the bottom most navigation controller will receive settings from the top most visible view controller.