Reputation: 2912
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
Upvotes: 1
Views: 9339
Reputation: 686
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
This can set the device orientation to LandscapeRight programmatically.
Upvotes: 1
Reputation: 355
This works for me on Xcode 6 & 5.
- (BOOL)shouldAutorotate {return YES;}
- (NSUInteger)supportedInterfaceOrientations {return (UIInterfaceOrientationMaskPortrait);}
Upvotes: 0
Reputation: 13346
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.
Upvotes: 1
Reputation: 4762
Actually you can force any rotation. At least I was able to do it. Solution I used: https://stackoverflow.com/a/10146270/894671
Upvotes: 0
Reputation: 1846
You can use the answer from jbat100 plus a call to setStatusBarOrientation:animated
in UIApplication to achieve the effect.
Upvotes: 1