3

I've implemented the proper functions, but they don't get triggered? I've tried several solutions here on StackOverFlow, but none of them work. I've tried adding the view to a UINavigationController, also doesn't work.

FakeIDDetailViewController.h:

@interface FakeIDDetailViewController : UIViewController
@end

FakeIDDetailViewController.m:

@interface FakeIDDetailViewController ()

-(BOOL)shouldAutorotate
{
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (UIInterfaceOrientationMaskLandscapeLeft);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

- (NSUInteger) application:(UIApplication *)application     supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationLandscapeLeft;
}
Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
  • What SO solutions have you tried? As you say, there are several... and I'd rather not list through them all. – nhgrif Feb 06 '14 at 22:56
  • possible duplicate of: http://stackoverflow.com/questions/19095161/force-landscape-ios-7 – Xu Yin Feb 06 '14 at 22:57
  • possible duplicate of [In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack](http://stackoverflow.com/questions/15300819/in-ios6-trouble-forcing-viewcontroller-to-certain-interfaceorientation-when-pus) – matt Feb 06 '14 at 23:05
  • try this: http://stackoverflow.com/questions/22491786/force-landscape-viewcontroller-in-ios-7/22491787#22491787 – Fede Cugliandolo Mar 19 '14 at 00:19
  • @Jim Clermonts you should accept an answer if one of them was helpful – race_carr May 18 '14 at 17:39

2 Answers2

4

If you are pushing a view controller to a stack of other view controllers in a navigation controller, requiring landscape only will not work well. You should display the landscape-constraint view controller modally.

See my answer here for an example project: https://stackoverflow.com/a/16022631/983912

Community
  • 1
  • 1
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
3

For a navigation controller interface, forcing an orientation is not supported by the framework. See my answer here: https://stackoverflow.com/a/15301322/341994

For a workaround (not very good), see my answer here: https://stackoverflow.com/a/16379515/341994

However, forcing an orientation works fine for a presented view controller.

Community
  • 1
  • 1
matt
  • 515,959
  • 87
  • 875
  • 1,141