I have a ebook reader app where in, i need to programmatically adjust the device orientation according to the layout of the page... i.e, The device should support all orientations for some pages and only landscape for some other pages. Is there anyway in which i can force a orientation change programatically
Asked
Active
Viewed 9,330 times
1
-
How about `setStatusBarOrientation:animated` in UIApplication ? – Marcelo Alves Nov 01 '11 at 11:02
6 Answers
1
Note that the behavior for this has changed as of iOS 6.0. For further info, see: Autorotate in iOS 6 has strange behaviour
The gist is that should/will/did/etc have been deprecated and have been replaced with a cleaner, more dynamic implementation. Which we should all be thankful for.
1
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
This can set the device orientation to LandscapeRight programmatically.

Hanton
- 616
- 1
- 6
- 13
1
You can use the answer from jbat100 plus a call to setStatusBarOrientation:animated
in UIApplication to achieve the effect.

Marcelo Alves
- 1,856
- 11
- 12
0
Actually you can force any rotation. At least I was able to do it. Solution I used: https://stackoverflow.com/a/10146270/894671

Community
- 1
- 1

Guntis Treulands
- 4,764
- 2
- 50
- 72
0
This works for me on Xcode 6 & 5.
- (BOOL)shouldAutorotate {return YES;}
- (NSUInteger)supportedInterfaceOrientations {return (UIInterfaceOrientationMaskPortrait);}

SamSmart
- 355
- 3
- 3