0

Right I have done a lot of research on this and have hit a block.

I am developing an app which has multiple view controllers. I have the 'homepage', if you will, which all the others views can be access from (this ViewController.m). I also then have a UINavigationController.m attached to the ViewController.m to allow a full navigation bar etc.

My problem is that I am wanting all views to be shown in portrait EXCEPT one view, which I only want in landscape. In my app options, I have set it to enable all orientations and then I was reading that you should override the main orientation in your root view controller (which I assume is the navigation controller?), so I add:

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

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

This overrides everything and only portrait works. I have then tried adding:

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

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

To the view that I want to have in landscape only but it fails to work in the simulator.

Can anyone provide me with a solution? :/

(I would like iOS5 and iOS6 support if possible)

[EDIT]

I should add, I haven't edited AppDelegate in any way.

  • for that one view you need portrait landscape both orientation support? – D-eptdeveloper Sep 03 '13 at 11:51
  • No I just need landscape for that one view. I want to force the portrait view on everything else and then force landscape on this one view. I was looking https://devforums.apple.com/message/744384#744384 at this, but I'm unsure as to where I'm going wrong – Prateek Biyani Sep 03 '13 at 11:55
  • Have to checked, last two methods supportedInterfaceOrientations & supportedInterfaceOrientations are placed in the view controller which u need only landscape orientation? – Ganapathy Sep 03 '13 at 12:04
  • try this link it might be a helpful one http://stackoverflow.com/questions/14633213/force-portrait-orientation-while-pushing-from-landscape-view-controller – Agent Chocks. Sep 03 '13 at 12:05
  • @Ganapathy - those methods have been added to the view controller that I want in landscape. – Prateek Biyani Sep 03 '13 at 12:07

0 Answers0