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
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.
This was addressed by: Guntis Treulands https://stackoverflow.com/a/10146270/894671
//-----------------------------------
// FORCE PORTRAIT CODE
//-----------------------------------
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[UIViewController alloc] init];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft );
}
As suggested on a related thread shouldAutorotateToInterfaceOrientation
is deprecated. Newer apps should leverage the following methods as described in Apple's UIViewController Class Reference until they themselves become deprecated:
shouldAutorotate
,preferredInterfaceOrientationForPresentation
; andattemptRotationToDeviceOrientation
.From what I understand it's best to use different View Controllers for views which need to lock into (i.e. have a preferred) orientation mode which differs from the last.