Rotate only one view

Good morning,


I searched for many hours but could not find a solution to my problem.

In my project I would like to enable rotating in landscape for just one View. All other Views should stay in portrait.

Is this somehow possible?

Thanks in advance for any help.

Enable the desired orientations in the app (under the target, General, Deployment Info, Device Orientation) and then add this to all views except the one you want to rotate:


-(BOOL)shouldAutorotate{
    return NO;
}

Not working, still rotating. Maybe because the ViewController is embedded in a TabBarController? And the other ViewControllers also have a NavigationController??


Thanks again

Yes, that would explain it.

You could try - supportedInterfaceOrientations





https://developer.apple.com/library/ios/qa/qa1688/_index.html


Beginning with iOS 6, only the topmost view controller (alongside the

UIApplication
object) participates in deciding whether to rotate in response to a change of the device's orientation. More often than not, the view controller displaying your content is a child of
UINavigationController
,
UITabBarController
, or a custom container view controller. You may find yourself needing to subclass a container view controller in order to modify the values returned by its
supportedInterfaceOrientations
and
shouldAutorotate
methods.
Rotate only one view
 
 
Q