In iOS5 you could use this snippet to force the orientation:
UIViewController *c = [[UIViewController alloc]init];
[self presentModalViewController:c animated:NO];
[self dismissModalViewControllerAnimated:NO];
[c release];
However this causes an EXC_BAD_ACCESS in iOS6. How can a certain orientation be forced in iOS6?
On an iPhone with a Home button, swipe up from the bottom of the screen to access it. On an iPhone without a Home button, swipe down from the top-right corner of the screen instead. Here, tap on the rotation lock icon (which looks like a lock with a circular arrow) to turn it on or off.
Android Settings Start by going to Settings => Display and locate the “Device rotation” setting. On my personal cell phone, tapping this will reveal two options: “Rotate the contents of the screen,” and “Stay in portrait view.”
How Do I Fix It? Swipe down from the top-right corner of the screen on an iPhone or iPad to open the Control Center, then tap the small lock icon to allow for screen rotation. If this doesn't work, try restarting the app or restarting your iPhone or iPad.
Select the Start button, then type settings. Select Settings > System > Display, and choose a screen orientation from the drop-down list next to Display orientation.
Just to complete the previous answer, you should do this:
UIViewController *viewController = [[UIViewController alloc] init];
[self presentViewController:viewController animated:NO completion:^{
[viewController dismissModalViewControllerAnimated:NO];
}];
And iOS 6 is no longer under NDA.
In case anyone still cares about this, here's the iOS6 code snippet (I placed it in my viewDidLoad routine):
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:viewController animated:NO completion:^{
[self dismissViewControllerAnimated:NO completion:nil];
}];
At first presentModalViewController
and dismissModalViewControllerAnimated
are deprecated and probably iOS6 will not use these methods correctly. You should use similar methods with complition block instead.
The second thing is that [self dismissModalViewControllerAnimated:NO];
tries to dismiss self firstly. Is this correct in your case?
And last thing iOS6 is under NDA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With