Would like everything on the screen (UI) to be able to rotate from landscape left to right or vica versa.
How do I go about doing this? Is this private?
I know that
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {}
lets you say which orientations the UI can be, but is there a way to force only one at a time?
Cheers
In iOS
[[UIDevice currentDevice] setDeviceOrientation:UIDeviceOrientationSomeOrientation]
method is absent. But we can rotate a view with status bar, for this:That method is called to determine whether your interface should automatically rotate to a given rotation (i.e letting UIKit do the hard work, rather than you doing it manually).
So if you wanted your app to only work in landscape you'd implement the body of that method with:
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
If you wanted your UI to auto rotate to all orientations you could just
return YES;
Is that what you were asking?
If you present a modal view controller which implements
-shouldAutorotateToInterfaceOrientation:
to only support one orientation, the whole interface will automatically be forced into it. I don't think there's a way to programmatically change orientation otherwise.I've had success with this:
In Swift to change the orientation to portrait:
See: https://stackoverflow.com/a/24259601